From 9bdfe9a9bc266332771fc894847b92a80535c00e Mon Sep 17 00:00:00 2001 From: imcuttle Date: Mon, 16 Apr 2018 19:37:16 +0800 Subject: [PATCH] fix: fix IE<=10 class static properties assign https://github.com/babel/babel/issues/2450 --- package-lock.json | 10 ++++++++ package.json | 43 +++++++++++++++++++++++----------- rollup.config.js | 59 +++++++++++++++++++++++++---------------------- 3 files changed, 71 insertions(+), 41 deletions(-) diff --git a/package-lock.json b/package-lock.json index 364f2b8..072716b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1896,6 +1896,16 @@ "babel-runtime": "6.26.0" } }, + "babel-plugin-transform-proto-to-assign": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-proto-to-assign/-/babel-plugin-transform-proto-to-assign-6.26.0.tgz", + "integrity": "sha1-xJPiSmJ0mkT37ellBsDLOhiR9ns=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "lodash": "4.17.5" + } + }, "babel-plugin-transform-react-display-name": { "version": "6.25.0", "resolved": "https://registry.npmjs.org/babel-plugin-transform-react-display-name/-/babel-plugin-transform-react-display-name-6.25.0.tgz", diff --git a/package.json b/package.json index 7d04700..7ba91dc 100644 --- a/package.json +++ b/package.json @@ -4,27 +4,24 @@ "description": "View & Model are mixed now via react mobx.", "scripts": { "babel": "rimraf packages && babel srcPackages -d packages -D", - "rollup": "rimraf dist && rollup -c --silent", + "rollup": "rimraf dist && rollup -c --silent && babel dist/*.js --plugins=transform-proto-to-assign --no-babelrc -d .", "watch": "npm run rollup -- -w", "prepare": "run-p rollup babel", "test:all": "npm run prepare && run-p test test:cy:run", "test": "jest && npm run size", - "test:cy:ci": - "npm-run-all --race --parallel \"gojs:open -- -s -i binding.js\" \"cy:run -- --record --key {1}\" --", + "test:cy:ci": "npm-run-all --race --parallel \"gojs:open -- -s -i binding.js\" \"cy:run -- --record --key {1}\" --", "test:cy:run": "run-p --race \"gojs -- -s\" cy:run", "test:cy:open": "run-p gojs cy:open", "gojs": "npm run gojs:open -- --noopen", "gojs:open": "gojs examples -p 8001", "cy:run": "cypress run", "cy:open": "cypress open", - "clean-picidae": - "rimraf node_modules/picidae/node_modules/{react,react-dom,react-router,history}", + "clean-picidae": "rimraf node_modules/picidae/node_modules/{react,react-dom,react-router,history}", "picidae": "picidae start -c _site/picidae.config.js", "lint": "eslint ./src --fix", "precommit": "lint-staged", "commitmsg": "commitlint -e $GIT_PARAMS", - "changelog": - "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md", + "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md", "gen-release-note": "node scripts/gen-release-notes.js", "preversion": "npm run test:all", "version": "run-p changelog gen-release-note", @@ -48,7 +45,10 @@ } ], "lint-staged": { - "src/**/*.{js,jsx}": ["eslint --fix", "git add"] + "src/**/*.{js,jsx}": [ + "eslint --fix", + "git add" + ] }, "main": "dist/react-mobx-vm.js", "module": "dist/react-mobx-vm.es.js", @@ -56,8 +56,15 @@ "cdn": "dist/react-mobx-vm.umd.min.js", "unpkg": "dist/react-mobx-vm.umd.min.js", "jsdelivr": "dist/react-mobx-vm.umd.min.js", - "files": ["dist", "packages"], - "keywords": ["imcuttle", "View & Model", "react-mobx-vm"], + "files": [ + "dist", + "packages" + ], + "keywords": [ + "imcuttle", + "View & Model", + "react-mobx-vm" + ], "author": "imcuttle", "license": "MIT", "peerDependencies": { @@ -77,6 +84,7 @@ "babel-plugin-transform-decorators-legacy": "^1.3.4", "babel-plugin-transform-export-extensions": "^6.22.0", "babel-plugin-transform-object-rest-spread": "^6.26.0", + "babel-plugin-transform-proto-to-assign": "^6.26.0", "babel-plugin-transform-react-jsx": "^6.24.1", "babel-plugin-transform-runtime": "^6.23.0", "babel-preset-env": "^1.6.1", @@ -128,8 +136,15 @@ "jest": { "testEnvironment": "jsdom", "setupTestFrameworkScriptFile": "/test/setup/react.js", - "collectCoverageFrom": ["src/**/*.js", "srcPackage/**/*.js"], - "coverageReporters": ["json", "text", "lcov"] + "collectCoverageFrom": [ + "src/**/*.js", + "srcPackage/**/*.js" + ], + "coverageReporters": [ + "json", + "text", + "lcov" + ] }, "dependencies": { "babel-runtime": "^6.26.0", @@ -150,6 +165,8 @@ } }, "commitlint": { - "extends": ["@commitlint/config-conventional"] + "extends": [ + "@commitlint/config-conventional" + ] } } diff --git a/rollup.config.js b/rollup.config.js index 1de488e..f05b357 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -25,27 +25,28 @@ const plugins = [ exclude: 'node_modules/**', runtimeHelpers: true, babelrc: false, - 'presets': [ + presets: [ [ 'env', { - 'targets': { - 'node': '6', - 'browsers': ['ie>=9'] + targets: { + node: '6', + browsers: ['ie>=9'] }, - 'loose': true, - 'useBuiltIns': true, - 'modules': false + loose: true, + useBuiltIns: true, + modules: false } ], 'react' ], - 'plugins': [ + plugins: [ 'external-helpers', // 'add-module-exports', [ - 'transform-react-jsx', { - 'pragma': 'h' + 'transform-react-jsx', + { + pragma: 'h' } ], 'lodash', @@ -57,10 +58,10 @@ const plugins = [ 'transform-runtime', { helpers: false, - 'polyfill': false, - 'regenerator': true + polyfill: false, + regenerator: true } - ] + ], ] }), resolve({ @@ -72,12 +73,7 @@ const plugins = [ filesize() ] -const external = [ - 'react', - 'mobx', - 'mobx-react', - 'prop-types' -] +const external = ['react', 'mobx', 'mobx-react', 'prop-types'] export default [ { @@ -103,9 +99,12 @@ export default [ name: 'reactMobxVM' }, external, - plugins: plugins.concat(uglify(), replace({ - 'process.env.NODE_ENV': JSON.stringify('production') - })), + plugins: plugins.concat( + uglify(), + replace({ + 'process.env.NODE_ENV': JSON.stringify('production') + }) + ), sourceMap: true }, { @@ -115,9 +114,11 @@ export default [ format: 'es' }, external: id => { - return id.startsWith('babel-runtime') - || id.startsWith('lodash') - || ['qs'].concat(external).includes(id) + return ( + id.startsWith('babel-runtime') || + id.startsWith('lodash') || + ['qs'].concat(external).includes(id) + ) }, plugins, sourceMap: true @@ -129,9 +130,11 @@ export default [ format: 'cjs' }, external: id => { - return id.startsWith('babel-runtime') - || id.startsWith('lodash') - || ['qs'].concat(external).includes(id) + return ( + id.startsWith('babel-runtime') || + id.startsWith('lodash') || + ['qs'].concat(external).includes(id) + ) }, plugins, sourceMap: true