diff --git a/build/fix-esm.js b/build/fix-esm.js new file mode 100755 index 00000000..e3f70374 --- /dev/null +++ b/build/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'); \ No newline at end of file diff --git a/package.json b/package.json index ef5a73ce..af3dc502 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,12 @@ "description": "Language service for CSS, LESS and SCSS", "main": "./lib/umd/cssLanguageService.js", "typings": "./lib/umd/cssLanguageService", - "module": "./lib/esm/cssLanguageService.js", + "exports": { + ".": { + "import": "./lib/esm/cssLanguageService.js", + "default": "./lib/umd/cssLanguageService.js" + } + }, "author": "Microsoft Corporation", "repository": { "type": "git", @@ -36,7 +41,7 @@ "scripts": { "prepack": "npm run clean && npm run compile-esm && npm run test && npm run remove-sourcemap-refs", "compile": "tsc -p ./src && npm run copy-jsbeautify && npm run lint ", - "compile-esm": "tsc -p ./src/tsconfig.esm.json", + "compile-esm": "tsc -p ./src/tsconfig.esm.json && node ./build/fix-esm.js", "clean": "rimraf lib", "remove-sourcemap-refs": "node ./build/remove-sourcemap-refs.js", "watch": "npm run copy-jsbeautify && tsc -w -p ./src", diff --git a/src/tsconfig.esm.json b/src/tsconfig.esm.json index 63606e2e..60208c5a 100644 --- a/src/tsconfig.esm.json +++ b/src/tsconfig.esm.json @@ -1,7 +1,7 @@ { "compilerOptions": { - "target": "es2020", - "module": "es6", + "target": "es6", + "module": "esnext", "moduleResolution": "node", "sourceMap": true, "declaration": true,