From 4b050c9558249bd3e1bceca6b703339536fe705b Mon Sep 17 00:00:00 2001 From: Paul Taylor Date: Mon, 20 Nov 2017 12:18:34 -0800 Subject: [PATCH 1/2] update text-encoding-utf-8 dependency with node ESModules support --- js/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/package.json b/js/package.json index 24bc27f5b63..3e9707a969f 100644 --- a/js/package.json +++ b/js/package.json @@ -90,7 +90,7 @@ "rxjs": "5.5.2", "shx": "0.2.2", "source-map-loader": "0.2.3", - "text-encoding-utf-8": "1.0.1", + "text-encoding-utf-8": "1.0.2", "trash": "4.1.0", "ts-jest": "21.2.1", "tslib": "1.8.0", From fbecde59154861bb49c44f2a4f2afd0238038760 Mon Sep 17 00:00:00 2001 From: Paul Taylor Date: Mon, 20 Nov 2017 15:31:41 -0800 Subject: [PATCH 2/2] synthesize an mjs file for tslib on postinstall --- js/gulp/package-task.js | 6 ++++++ js/package.json | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) 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 3e9707a969f..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.2", "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",