Pārlūkot izejas kodu

feat: add exports field + mjs build

Evan You 3 gadi atpakaļ
vecāks
revīzija
d3172377e0
4 mainītis faili ar 25 papildinājumiem un 0 dzēšanām
  1. 1 0
      compiler-sfc/index.mjs
  2. 1 0
      compiler-sfc/package.json
  3. 16 0
      package.json
  4. 7 0
      scripts/config.js

+ 1 - 0
compiler-sfc/index.mjs

@@ -0,0 +1 @@
+export * from '@vue/compiler-sfc'

+ 1 - 0
compiler-sfc/package.json

@@ -1,4 +1,5 @@
 {
   "main": "index.js",
+  "module": "index.mjs",
   "types": "index.d.ts"
 }

+ 16 - 0
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",

+ 7 - 0
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'),