浏览代码

add esm build

Evan You 8 年之前
父节点
当前提交
f33d375703
共有 2 个文件被更改,包括 5 次插入3 次删除
  1. 2 2
      build/rollup.config.js
  2. 3 1
      package.json

+ 2 - 2
build/rollup.config.js

@@ -4,8 +4,8 @@ const version = process.env.VERSION || require('../package.json').version
 
 module.exports = {
   entry: 'src/index.js',
-  dest: 'dist/vuex.js',
-  format: 'umd',
+  dest: process.env.ESM ? 'dist/vuex.esm.js' : 'dist/vuex.js',
+  format: process.env.ESM ? 'es' : 'umd',
   moduleName: 'Vuex',
   plugins: [
     replace({ __VERSION__: version }),

+ 3 - 1
package.json

@@ -3,6 +3,7 @@
   "version": "2.1.3",
   "description": "state management for Vue.js",
   "main": "dist/vuex.js",
+  "module": "dist/vuex.esm.js",
   "typings": "types/index.d.ts",
   "files": [
     "dist",
@@ -14,8 +15,9 @@
   "scripts": {
     "dev": "node examples/server.js",
     "dev:dist": "rollup -wm -c build/rollup.config.js",
-    "build": "npm run build:main && npm run build:logger",
+    "build": "npm run build:main && npm run build:esm && npm run build:logger",
     "build:main": "rollup -c build/rollup.config.js && uglifyjs dist/vuex.js -cm --comments -o dist/vuex.min.js",
+    "build:esm": "rollup -c build/rollup.config.js --environment ESM",
     "build:logger": "rollup -c build/rollup.logger.config.js",
     "lint": "eslint src test",
     "test": "npm run lint && npm run test:types && npm run test:unit && npm run test:e2e",