diff --git a/build/bin/fix-esm.js b/build/bin/fix-esm.js new file mode 100644 index 000000000..a780d6f1f --- /dev/null +++ b/build/bin/fix-esm.js @@ -0,0 +1,12 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +'use strict'; +//@ts-check + +const fs = require('fs'); + +const pkg = { type: 'module' }; + +fs.writeFileSync('lib/esm/package.json', JSON.stringify(pkg, undefined, 2) + '\n'); diff --git a/textDocument/package.json b/textDocument/package.json index 02c007995..7d1ce619d 100644 --- a/textDocument/package.json +++ b/textDocument/package.json @@ -14,7 +14,12 @@ }, "main": "./lib/umd/main.js", "typings": "./lib/umd/main", - "module": "./lib/esm/main.js", + "exports": { + ".": { + "import": "./lib/esm/main.js", + "default": "./lib/umd/main.js" + } + }, "scripts": { "prepublishOnly": "echo \"⛔ Can only publish from a secure pipeline ⛔\" && node ../build/npm/fail", "prepack": "npm run all:publish", @@ -24,7 +29,7 @@ "lint": "node ../node_modules/eslint/bin/eslint.js --ext ts src", "test": "node ../node_modules/mocha/bin/_mocha", "all": "npm run clean && npm run compile && npm run lint && npm run test", - "compile:esm": "node ../build/bin/tsc -b ./tsconfig.esm.publish.json", + "compile:esm": "node ../build/bin/tsc -b ./tsconfig.esm.publish.json && node ../build/bin/fix-esm", "compile:umd": "node ../build/bin/tsc -b ./tsconfig.umd.publish.json", "all:publish": "git clean -xfd . && npm install && npm run compile:esm && npm run compile:umd && npm run lint && npm run test", "preversion": "npm test" diff --git a/textDocument/src/test/tsconfig.esm.publish.json b/textDocument/src/test/tsconfig.esm.publish.json index 7a82556b4..809d377f5 100644 --- a/textDocument/src/test/tsconfig.esm.publish.json +++ b/textDocument/src/test/tsconfig.esm.publish.json @@ -13,7 +13,7 @@ "declaration": true, "stripInternal": true, "sourceMap": false, - "target": "es5", + "target": "es6", "lib": [ "es2015" ], diff --git a/textDocument/src/tsconfig.esm.publish.json b/textDocument/src/tsconfig.esm.publish.json index 2320a2e45..d1a487774 100644 --- a/textDocument/src/tsconfig.esm.publish.json +++ b/textDocument/src/tsconfig.esm.publish.json @@ -11,7 +11,7 @@ "declaration": true, "stripInternal": true, "sourceMap": false, - "target": "es5", + "target": "es6", "lib": [ "es2015" ], diff --git a/types/package.json b/types/package.json index 92553f650..1ec4729e7 100644 --- a/types/package.json +++ b/types/package.json @@ -14,7 +14,12 @@ }, "main": "./lib/umd/main.js", "typings": "./lib/umd/main", - "module": "./lib/esm/main.js", + "exports": { + ".": { + "import": "./lib/esm/main.js", + "default": "./lib/umd/main.js" + } + }, "scripts": { "prepublishOnly": "echo \"⛔ Can only publish from a secure pipeline ⛔\" && node ../build/npm/fail", "prepack": "npm run all:publish", @@ -24,7 +29,7 @@ "lint": "node ../node_modules/eslint/bin/eslint.js --ext ts src", "test": "node ../node_modules/mocha/bin/_mocha", "all": "npm run clean && npm run compile && npm run lint && npm run test", - "compile:esm": "node ../build/bin/tsc -b ./tsconfig.esm.publish.json", + "compile:esm": "node ../build/bin/tsc -b ./tsconfig.esm.publish.json && node ../build/bin/fix-esm", "compile:umd": "node ../build/bin/tsc -b ./tsconfig.umd.publish.json", "all:publish": "git clean -xfd . && npm install && npm run compile:esm && npm run compile:umd && npm run lint && npm run test", "preversion": "npm test" diff --git a/types/src/test/tsconfig.esm.publish.json b/types/src/test/tsconfig.esm.publish.json index 7a82556b4..809d377f5 100644 --- a/types/src/test/tsconfig.esm.publish.json +++ b/types/src/test/tsconfig.esm.publish.json @@ -13,7 +13,7 @@ "declaration": true, "stripInternal": true, "sourceMap": false, - "target": "es5", + "target": "es6", "lib": [ "es2015" ], diff --git a/types/src/tsconfig.esm.publish.json b/types/src/tsconfig.esm.publish.json index 2320a2e45..d1a487774 100644 --- a/types/src/tsconfig.esm.publish.json +++ b/types/src/tsconfig.esm.publish.json @@ -11,7 +11,7 @@ "declaration": true, "stripInternal": true, "sourceMap": false, - "target": "es5", + "target": "es6", "lib": [ "es2015" ],