diff --git a/js/gulp/package-task.js b/js/gulp/package-task.js index 7b4b15a33e6..ad56d172eae 100644 --- a/js/gulp/package-task.js +++ b/js/gulp/package-task.js @@ -49,6 +49,12 @@ const createMainPackageJson = (target, format) => (orig) => ({ browser: `${mainExport}.es5.min.js`, [`browser:es2015`]: `${mainExport}.es2015.min.js`, [`@std/esm`]: { esm: `mjs` }, + // Temporary workaround until https://github.com/Microsoft/tslib/pull/44 is merged + scripts: { + postinstall: `npm i shx && npm run tslib_mjs && npm run tslib_pkg && npm r shx`, + tslib_mjs: `shx cp $(node -e \"console.log(require.resolve('tslib/tslib.es6.js'))\") $(node -e \"var r=require,p=r('path');console.log(p.join(p.dirname(r.resolve('tslib')),'tslib.mjs'))\")`, + tslib_pkg: `node -e \"var r=require,p=r('path'),f=r('fs'),k=p.join(p.dirname(r.resolve('tslib')),'package.json'),x=JSON.parse(f.readFileSync(k));x.main='tslib';f.writeFileSync(k,JSON.stringify(x))\"` + } }); const createTypeScriptPackageJson = (target, format) => (orig) => ({ diff --git a/js/package.json b/js/package.json index 24bc27f5b63..1a110b2d5de 100644 --- a/js/package.json +++ b/js/package.json @@ -25,7 +25,8 @@ "lint": "npm-run-all -p lint:*", "lint:src": "tslint --fix --project -p tsconfig.json -c tslint.json \"src/**/*.ts\"", "lint:test": "tslint --fix --project -p test/tsconfig.json -c tslint.json \"test/**/*.ts\"", - "prepublishOnly": "echo \"Error: do 'npm run release' instead of 'npm publish'\" && exit 1" + "prepublishOnly": "echo \"Error: do 'npm run release' instead of 'npm publish'\" && exit 1", + "postinstall": "shx cp node_modules/tslib/tslib.es6.js node_modules/tslib/tslib.mjs" }, "repository": { "type": "git", @@ -54,7 +55,8 @@ }, "dependencies": { "flatbuffers": "trxcllnt/flatbuffers-esm", - "text-encoding": "0.6.4" + "text-encoding-utf-8": "^1.0.2", + "tslib": "^1.8.0" }, "devDependencies": { "@std/esm": "0.13.0", @@ -90,10 +92,8 @@ "rxjs": "5.5.2", "shx": "0.2.2", "source-map-loader": "0.2.3", - "text-encoding-utf-8": "1.0.1", "trash": "4.1.0", "ts-jest": "21.2.1", - "tslib": "1.8.0", "tslint": "5.8.0", "typescript": "2.6.1", "uglifyjs-webpack-plugin": "1.0.1",