From d3172377e0c2df9e84244ede6fc9a091344e6f1c Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 1 Jun 2022 10:11:19 +0800 Subject: [PATCH] feat: add exports field + mjs build --- compiler-sfc/index.mjs | 1 + compiler-sfc/package.json | 1 + package.json | 16 ++++++++++++++++ scripts/config.js | 7 +++++++ 4 files changed, 25 insertions(+) create mode 100644 compiler-sfc/index.mjs diff --git a/compiler-sfc/index.mjs b/compiler-sfc/index.mjs new file mode 100644 index 00000000000..3c30abc8ccf --- /dev/null +++ b/compiler-sfc/index.mjs @@ -0,0 +1 @@ +export * from '@vue/compiler-sfc' diff --git a/compiler-sfc/package.json b/compiler-sfc/package.json index d7ccd0a7b03..778c7ebf51c 100644 --- a/compiler-sfc/package.json +++ b/compiler-sfc/package.json @@ -1,4 +1,5 @@ { "main": "index.js", + "module": "index.mjs", "types": "index.d.ts" } diff --git a/package.json b/package.json index 6b0049d5959..8b9e71fbba1 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,22 @@ "compiler-sfc", "packages/compiler-sfc" ], + "exports": { + ".": { + "import": { + "node": "./dist/vue.runtime.mjs", + "default": "./dist/vue.runtime.esm.js" + }, + "require": "./dist/vue.runtime.common.js", + "types": "./types/index.d.ts" + }, + "./compiler-sfc": { + "import": "./compiler-sfc/index.mjs", + "require": "./compiler-sfc/index.js" + }, + "./dist/*": "./dist/*", + "./types/*": "./types/*" + }, "sideEffects": false, "scripts": { "dev": "rollup -w -c scripts/config.js --environment TARGET:full-dev", diff --git a/scripts/config.js b/scripts/config.js index 2360c8026cf..610e8d0a9ee 100644 --- a/scripts/config.js +++ b/scripts/config.js @@ -65,6 +65,13 @@ const builds = { format: 'es', banner }, + // Runtime only ES modules build (for Node) + 'runtime-mjs': { + entry: resolve('web/entry-runtime-esm.ts'), + dest: resolve('dist/vue.runtime.mjs'), + format: 'es', + banner + }, // Runtime+compiler ES modules build (for bundlers) 'full-esm': { entry: resolve('web/entry-runtime-with-compiler-esm.ts'),