From f159337e9d778eabea1f90978045208d6cd5fa38 Mon Sep 17 00:00:00 2001 From: yangfan <18767120422@163.com> Date: Tue, 15 Oct 2019 17:16:04 +0800 Subject: [PATCH 01/10] feat: DCE require --- packages/driver-universal/src/index.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/driver-universal/src/index.js b/packages/driver-universal/src/index.js index e089f25ca1..de822e3061 100644 --- a/packages/driver-universal/src/index.js +++ b/packages/driver-universal/src/index.js @@ -1,12 +1,10 @@ import { isWeex, isWeb } from 'universal-env'; -import DriverDOM from './dom'; -import DriverWeex from './weex'; let DriverUniversal; if (isWeex) { - DriverUniversal = DriverWeex; + DriverUniversal = require('./weex').default; } else if (isWeb) { - DriverUniversal = DriverDOM; + DriverUniversal = require('./dom').default; } else { throw new Error('Your environment not supported by driver-universal.'); } From c933f5efd5a705f55712291e1e56b98f5998bdcc Mon Sep 17 00:00:00 2001 From: Orange-C Date: Wed, 16 Oct 2019 17:35:16 +0800 Subject: [PATCH 02/10] feat: add es compile --- .eslintignore | 1 + .gitignore | 1 + babel.config.js | 27 ----------- package.json | 3 ++ packages/driver-universal/package.json | 1 + packages/rax-app/package.json | 3 +- packages/rax-app/src/runApp.js | 8 +++- scripts/compile-packages.js | 2 +- scripts/compile.js | 65 +++++++++++--------------- scripts/config/getBabelConfig.js | 30 ++++++++++++ scripts/dist-builtins.js | 4 +- scripts/dist-core.js | 29 ++++++------ scripts/dist-packages.js | 2 +- scripts/dist-universal.js | 2 +- 14 files changed, 90 insertions(+), 88 deletions(-) delete mode 100644 babel.config.js create mode 100644 scripts/config/getBabelConfig.js diff --git a/.eslintignore b/.eslintignore index 4678726ff4..2557569aad 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,5 +1,6 @@ node_modules lib +es dist build coverage diff --git a/.gitignore b/.gitignore index 0eeb2632f2..99409d85cb 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ npm-debug.log lerna-debug.log npm-debug.log* lib/ +es/ dist/ build/ coverage/ diff --git a/babel.config.js b/babel.config.js deleted file mode 100644 index ccf815fd17..0000000000 --- a/babel.config.js +++ /dev/null @@ -1,27 +0,0 @@ -module.exports = function(api) { - // Cache the returned value forever and don't call this function again. - if (api) api.cache(true); - - return { - 'presets': [ - '@babel/preset-flow', - ['@babel/preset-env', { - 'loose': true - }], - ['@babel/preset-react', { - 'pragma': 'createElement' - }] - ], - 'plugins': [ - '@babel/plugin-proposal-export-default-from', - ['@babel/plugin-proposal-class-properties', { 'loose': false }], - 'babel-plugin-transform-jsx-stylesheet', - ['@babel/plugin-proposal-decorators', { 'legacy': true }], - ], - 'ignore': [ - 'src/generator/templates', - '__mockc__', - 'dist' - ], - }; -}; diff --git a/package.json b/package.json index 036a7a6a2e..de3986f5f8 100644 --- a/package.json +++ b/package.json @@ -86,5 +86,8 @@ "commitizen": { "path": "./node_modules/cz-conventional-changelog" } + }, + "dependencies": { + "babel-merge": "^3.0.0" } } diff --git a/packages/driver-universal/package.json b/packages/driver-universal/package.json index d4e85a1257..f867d0c61b 100644 --- a/packages/driver-universal/package.json +++ b/packages/driver-universal/package.json @@ -4,6 +4,7 @@ "description": "Driver for Universal App.", "license": "BSD-3-Clause", "main": "lib/index.js", + "module": "es/index.js", "repository": { "type": "git", "url": "git+https://github.com/alibaba/rax.git" diff --git a/packages/rax-app/package.json b/packages/rax-app/package.json index 0df514e146..e27bf347c7 100644 --- a/packages/rax-app/package.json +++ b/packages/rax-app/package.json @@ -3,6 +3,7 @@ "version": "0.1.1", "description": "Rax application framework for univesal app.", "main": "lib/index.js", + "module": "es/index.js", "author": "Rax Team", "repository": { "type": "git", @@ -22,4 +23,4 @@ "peerDependencies": { "rax": "^1.0.8" } -} \ No newline at end of file +} diff --git a/packages/rax-app/src/runApp.js b/packages/rax-app/src/runApp.js index 6dc98d1f96..0ad1d38fb1 100644 --- a/packages/rax-app/src/runApp.js +++ b/packages/rax-app/src/runApp.js @@ -1,7 +1,10 @@ import { render, createElement, useState, useEffect } from 'rax'; import { isWeex, isWeb } from 'universal-env'; import { useRouter } from 'rax-use-router'; -import { createMemoryHistory, createHashHistory, createBrowserHistory } from 'history'; +// import { createMemoryHistory, createHashHistory, createBrowserHistory } from 'history'; +// import { createMemoryHistory } from 'history'; +import * as hisaaa from 'history'; +const createMemoryHistory = hisaaa.createMemoryHistory; import UniversalDriver from 'driver-universal'; import { emit } from './app'; @@ -71,12 +74,15 @@ export default function runApp(appConfig) { const { routes, shell, hydrate = false } = appConfig; if (isWeex) { + console.log('9999999999') history = createMemoryHistory(); } else if (initialDataFromSSR) { + console.log('8888888888') // If that contains `initialDataFromSSR`, which means SSR is enabled, // we should use brower history to make it works. history = createBrowserHistory(); } else { + console.log('7777777777') history = createHashHistory(); } diff --git a/scripts/compile-packages.js b/scripts/compile-packages.js index a956750b37..a616e3dd89 100644 --- a/scripts/compile-packages.js +++ b/scripts/compile-packages.js @@ -13,4 +13,4 @@ const compile = require('./compile'); compile('packages'); - +compile('packages', true); diff --git a/scripts/compile.js b/scripts/compile.js index 57ba533c6a..9689213716 100644 --- a/scripts/compile.js +++ b/scripts/compile.js @@ -22,17 +22,13 @@ const parseArgs = require('minimist'); const chokidar = require('chokidar'); const SRC_DIR = 'src'; -const BUILD_DIR = 'lib'; const JS_FILES_PATTERN = '**/*.js'; const IGNORE_PATTERN = '**/{__tests__,__mocks__}/**'; const args = parseArgs(process.argv); const customPackages = args.packages; -const babelOptions = require('../babel.config')(); - -babelOptions.babelrc = false; -// babelOptions.sourceMaps = 'inline'; +const getBabelConfig = require('./config/getBabelConfig'); const fixedWidth = str => { const WIDTH = 80; @@ -44,7 +40,7 @@ const fixedWidth = str => { return strs.slice(0, -1).concat(lastString).join('\n'); }; -function buildPackage(packagesDir, p) { +function buildPackage(packagesDir, p, isBuildEs) { const srcDir = path.resolve(p, SRC_DIR); const pattern = path.resolve(srcDir, '**/*'); const files = glob.sync(pattern, {nodir: true}); @@ -53,7 +49,7 @@ function buildPackage(packagesDir, p) { fixedWidth(`${path.basename(p)}\n`) ); - files.forEach(file => buildFile(packagesDir, file, true)); + files.forEach(file => buildFile(packagesDir, file, isBuildEs)); process.stdout.write(`[ ${chalk.green('OK')} ]\n`); } @@ -71,51 +67,40 @@ function getPackages(packagesDir, customPackages) { .filter(f => fs.lstatSync(path.resolve(f)).isDirectory()); } -function buildFile(packagesDir, file, silent) { +function buildFile(packagesDir, file, isBuildEs) { + const BUILD_DIR = isBuildEs ? 'es' : 'lib'; const packageName = path.relative(packagesDir, file).split(path.sep)[0]; const packageSrcPath = path.resolve(packagesDir, packageName, SRC_DIR); const packageBuildPath = path.resolve(packagesDir, packageName, BUILD_DIR); const relativeToSrcPath = path.relative(packageSrcPath, file); const destPath = path.resolve(packageBuildPath, relativeToSrcPath); - spawnSync('mkdir', ['-p', path.dirname(destPath)]); - if (minimatch(file, IGNORE_PATTERN)) { - silent || process.stdout.write( - chalk.dim(' \u2022 ') + - path.relative(packagesDir, file) + - ' (ignore)\n' - ); - } else if (!minimatch(file, JS_FILES_PATTERN)) { - fs.createReadStream(file).pipe(fs.createWriteStream(destPath)); - silent || process.stdout.write( - chalk.red(' \u2022 ') + - path.relative(packagesDir, file) + - chalk.red(' \u21D2 ') + - path.relative(packagesDir, destPath) + - ' (copy)' + - '\n' - ); + let babelOptions; + if (isBuildEs) { + babelOptions = getBabelConfig(true); } else { - const transformed = babel.transformFileSync(file, babelOptions).code; - spawnSync('mkdir', ['-p', path.dirname(destPath)]); - fs.writeFileSync(destPath, transformed); - silent || process.stdout.write( - chalk.green(' \u2022 ') + - path.relative(packagesDir, file) + - chalk.green(' \u21D2 ') + - path.relative(packagesDir, destPath) + - '\n' - ); + babelOptions = getBabelConfig(); + } + + spawnSync('mkdir', ['-p', path.dirname(destPath)]); + if (!minimatch(file, IGNORE_PATTERN)) { + if (!minimatch(file, JS_FILES_PATTERN)) { + fs.createReadStream(file).pipe(fs.createWriteStream(destPath)); + } else { + const transformed = babel.transformFileSync(file, babelOptions).code; + spawnSync('mkdir', ['-p', path.dirname(destPath)]); + fs.writeFileSync(destPath, transformed); + } } } // const packagesDir = path.resolve(__dirname, '../packages'); -module.exports = function compile(packagesName) { +module.exports = function compile(packagesName, isBuildEs) { const packagesDir = path.resolve(__dirname, `../${packagesName}`); + const packages = getPackages(packagesDir, customPackages); if (args.watch) { // watch packages - const packages = getPackages(packagesDir, customPackages); const watchPackagesDir = packages.map(dir => path.resolve(dir, SRC_DIR)); console.log(chalk.green('watch packages compile', packages)); @@ -127,13 +112,15 @@ module.exports = function compile(packagesName) { const packagePath = path.resolve(__dirname, `../${packagesName}/`, packageName); process.stdout.write(chalk.bold.inverse(`Compiling package ${packageName} \n`)); try { - buildPackage(packagesDir, packagePath); + buildPackage(packagesDir, packagePath, isBuildEs); } catch (e) {} process.stdout.write('\n'); }); } else { process.stdout.write(chalk.bold.inverse('Compiling packages\n')); - getPackages(packagesDir, customPackages).forEach(buildPackage.bind(null, packagesDir)); + packages.forEach((v) => { + buildPackage(packagesDir, v, isBuildEs); + }); process.stdout.write('\n'); } }; diff --git a/scripts/config/getBabelConfig.js b/scripts/config/getBabelConfig.js new file mode 100644 index 0000000000..a992d810f7 --- /dev/null +++ b/scripts/config/getBabelConfig.js @@ -0,0 +1,30 @@ +module.exports = function(ignoreModule) { + const envOpt = { + loose: true, + }; + + if (ignoreModule) { + envOpt.modules = false; + } + + return { + presets: [ + '@babel/preset-flow', + ['@babel/preset-env', envOpt], + ['@babel/preset-react', { + pragma: 'createElement' + }] + ], + plugins: [ + '@babel/plugin-proposal-export-default-from', + ['@babel/plugin-proposal-class-properties', { loose: false }], + 'babel-plugin-transform-jsx-stylesheet', + ['@babel/plugin-proposal-decorators', { legacy: true }], + ], + ignore: [ + 'src/generator/templates', + '__mockc__', + 'dist' + ], + }; +}; diff --git a/scripts/dist-builtins.js b/scripts/dist-builtins.js index 2bb20b56b2..37a1c13773 100644 --- a/scripts/dist-builtins.js +++ b/scripts/dist-builtins.js @@ -10,7 +10,7 @@ const fs = require('fs'); // build packages const PACKAGES_NAME = 'packages'; const PACKAGES_DIR = path.resolve(__dirname, `../${PACKAGES_NAME}`); -const babelOptions = require('../babel.config')(); +const babelOptions = require('./config/getBabelConfig')(); let packageList = fs.readdirSync(PACKAGES_DIR); let buildinObj = {}; @@ -175,4 +175,4 @@ function dist(config) { resolver(); }); }); -} \ No newline at end of file +} diff --git a/scripts/dist-core.js b/scripts/dist-core.js index fe052fc76f..5f76aaabfb 100755 --- a/scripts/dist-core.js +++ b/scripts/dist-core.js @@ -8,6 +8,9 @@ const babel = require('rollup-plugin-babel'); const { uglify } = require('rollup-plugin-uglify'); const replace = require('rollup-plugin-replace'); const gzipSize = require('gzip-size'); +const babelMerge = require('babel-merge'); + +const babelOptions = require('./config/getBabelConfig')(); const IIFE = 'iife'; const UMD = 'umd'; @@ -76,7 +79,7 @@ async function build({ package: packageName, entry = 'src/index.js', name, shoul // use /pakacges/ would get error and it seemed to be a rollup-plugin-commonjs bug include: /(node_modules|style-unit)/, }), - babel({ + babel(babelMerge(babelOptions, { exclude: 'node_modules/**', // only transpile our source code presets: [ ['@babel/preset-env', { @@ -87,7 +90,7 @@ async function build({ package: packageName, entry = 'src/index.js', name, shoul } }] ], - }), + })), replace({ 'process.env.NODE_ENV': JSON.stringify(shouldMinify ? 'production' : 'development'), }), @@ -118,20 +121,16 @@ async function build({ package: packageName, entry = 'src/index.js', name, shoul } } -build({ package: 'rax', name: 'Rax' }); -build({ package: 'rax', name: 'Rax', format: IIFE }); -build({ package: 'rax', name: 'Rax', format: IIFE, shouldMinify: true }); -build({ package: 'rax', name: 'Rax', format: ESM }); - -build({ package: 'driver-dom', name: 'DriverDOM' }); -build({ package: 'driver-dom', name: 'DriverDOM', format: IIFE }); -build({ package: 'driver-dom', name: 'DriverDOM', format: IIFE, shouldMinify: true }); -build({ package: 'driver-dom', name: 'DriverDOM', format: ESM }); +function buildCorePackages(packageName, name) { + build({ package: packageName, name: name }); + build({ package: packageName, name: name, format: IIFE }); + build({ package: packageName, name: name, format: IIFE, shouldMinify: true }); + build({ package: packageName, name: name, format: ESM }); +} -build({ package: 'driver-weex', name: 'DriverWeex' }); -build({ package: 'driver-weex', name: 'DriverWeex', format: IIFE }); -build({ package: 'driver-weex', name: 'DriverWeex', format: IIFE, shouldMinify: true }); -build({ package: 'driver-weex', name: 'DriverWeex', format: ESM }); +buildCorePackages('rax', 'Rax'); +buildCorePackages('driver-dom', 'DriverDOM'); +buildCorePackages('driver-weex', 'DriverWeex'); build({ package: 'driver-worker', name: 'DriverWorker' }); build({ package: 'driver-worker', name: 'DriverWorker', format: IIFE, shouldExportDefault: true }); diff --git a/scripts/dist-packages.js b/scripts/dist-packages.js index a786d7fb9d..b97f558889 100755 --- a/scripts/dist-packages.js +++ b/scripts/dist-packages.js @@ -4,7 +4,7 @@ const path = require('path'); const webpack = require('webpack'); const RaxPlugin = require('rax-webpack-plugin'); const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); -const babelOptions = require('../babel.config')(); +const babelOptions = require('./config/getBabelConfig')(); dist(getConfig( { diff --git a/scripts/dist-universal.js b/scripts/dist-universal.js index e11757774b..ddc601de2e 100755 --- a/scripts/dist-universal.js +++ b/scripts/dist-universal.js @@ -8,7 +8,7 @@ const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); const fs = require('fs'); const PACKAGES_DIR = path.resolve(__dirname, '../universal'); -const babelOptions = require('../babel.config')(); +const babelOptions = require('./config/getBabelConfig')(); function normalizeGlobalName(name) { return uppercamelcase(name); From d5fcc590facdc1299c9632346643a92e42bfdb1d Mon Sep 17 00:00:00 2001 From: Orange-C Date: Wed, 16 Oct 2019 17:53:39 +0800 Subject: [PATCH 03/10] fix: rm console --- packages/rax-app/src/runApp.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/packages/rax-app/src/runApp.js b/packages/rax-app/src/runApp.js index 0ad1d38fb1..6dc98d1f96 100644 --- a/packages/rax-app/src/runApp.js +++ b/packages/rax-app/src/runApp.js @@ -1,10 +1,7 @@ import { render, createElement, useState, useEffect } from 'rax'; import { isWeex, isWeb } from 'universal-env'; import { useRouter } from 'rax-use-router'; -// import { createMemoryHistory, createHashHistory, createBrowserHistory } from 'history'; -// import { createMemoryHistory } from 'history'; -import * as hisaaa from 'history'; -const createMemoryHistory = hisaaa.createMemoryHistory; +import { createMemoryHistory, createHashHistory, createBrowserHistory } from 'history'; import UniversalDriver from 'driver-universal'; import { emit } from './app'; @@ -74,15 +71,12 @@ export default function runApp(appConfig) { const { routes, shell, hydrate = false } = appConfig; if (isWeex) { - console.log('9999999999') history = createMemoryHistory(); } else if (initialDataFromSSR) { - console.log('8888888888') // If that contains `initialDataFromSSR`, which means SSR is enabled, // we should use brower history to make it works. history = createBrowserHistory(); } else { - console.log('7777777777') history = createHashHistory(); } From 2c7061af74994f5f9824354a9e124e69cbab6668 Mon Sep 17 00:00:00 2001 From: Orange-C Date: Wed, 16 Oct 2019 18:57:55 +0800 Subject: [PATCH 04/10] feat: update driver pkg --- packages/driver-dom/package.json | 1 + packages/driver-weex/package.json | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/driver-dom/package.json b/packages/driver-dom/package.json index 534a700703..6fb98ee599 100644 --- a/packages/driver-dom/package.json +++ b/packages/driver-dom/package.json @@ -4,6 +4,7 @@ "description": "DOM driver for Rax", "license": "BSD-3-Clause", "main": "lib/index.js", + "module": "es/index.js", "repository": { "type": "git", "url": "git+https://github.com/alibaba/rax.git" diff --git a/packages/driver-weex/package.json b/packages/driver-weex/package.json index 81797e7e71..ce92a2c576 100644 --- a/packages/driver-weex/package.json +++ b/packages/driver-weex/package.json @@ -4,6 +4,7 @@ "description": "Weex driver for Rax", "license": "BSD-3-Clause", "main": "lib/index.js", + "module": "es/index.js", "repository": { "type": "git", "url": "git+https://github.com/alibaba/rax.git" @@ -12,4 +13,4 @@ "url": "https://github.com/alibaba/rax/issues" }, "homepage": "https://github.com/alibaba/rax#readme" -} \ No newline at end of file +} From bed191fd99737e15ca1b365c6a829e08a94d8a14 Mon Sep 17 00:00:00 2001 From: yangfan <18767120422@163.com> Date: Wed, 16 Oct 2019 19:41:38 +0800 Subject: [PATCH 05/10] feat: update --- packages/driver-universal/src/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/driver-universal/src/index.js b/packages/driver-universal/src/index.js index de822e3061..e089f25ca1 100644 --- a/packages/driver-universal/src/index.js +++ b/packages/driver-universal/src/index.js @@ -1,10 +1,12 @@ import { isWeex, isWeb } from 'universal-env'; +import DriverDOM from './dom'; +import DriverWeex from './weex'; let DriverUniversal; if (isWeex) { - DriverUniversal = require('./weex').default; + DriverUniversal = DriverWeex; } else if (isWeb) { - DriverUniversal = require('./dom').default; + DriverUniversal = DriverDOM; } else { throw new Error('Your environment not supported by driver-universal.'); } From 7bc66b8ec9d8ba15dfe5b6e6ef45487a29fb0ad3 Mon Sep 17 00:00:00 2001 From: yangfan <18767120422@163.com> Date: Thu, 17 Oct 2019 11:23:00 +0800 Subject: [PATCH 06/10] fix: setRem undefined --- packages/driver-universal/src/weex.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/driver-universal/src/weex.js b/packages/driver-universal/src/weex.js index b3c2cd4331..e29259bbc0 100644 --- a/packages/driver-universal/src/weex.js +++ b/packages/driver-universal/src/weex.js @@ -1,12 +1,12 @@ import * as DriverWeex from 'driver-weex'; -import { convertUnit, setRem } from 'style-unit'; +import { convertUnit, setRpx } from 'style-unit'; const driver = Object.assign({}, DriverWeex, { beforeRender() { // Turn off batched updates document.open(); // Init rem unit - setRem( 1 ); + setRpx( 1 ); }, createElement(type, props = {}) { const style = {}; From dcd2b10fecb90a68607b79bcf38d7dad13170093 Mon Sep 17 00:00:00 2001 From: yangfan <18767120422@163.com> Date: Thu, 17 Oct 2019 11:30:53 +0800 Subject: [PATCH 07/10] feat: update rax-app version --- packages/rax-app/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/rax-app/package.json b/packages/rax-app/package.json index e27bf347c7..19ee2d4e36 100644 --- a/packages/rax-app/package.json +++ b/packages/rax-app/package.json @@ -1,6 +1,6 @@ { "name": "rax-app", - "version": "0.1.1", + "version": "0.2.0", "description": "Rax application framework for univesal app.", "main": "lib/index.js", "module": "es/index.js", @@ -14,7 +14,7 @@ }, "homepage": "https://github.com/alibaba/rax#readme", "dependencies": { - "driver-universal": "^1.0.2", + "driver-universal": "^2.0.0", "history": "^4.9.0", "querystring": "^0.2.0", "rax-use-router": "^3.0.0", From d3709549a562e5237f48d331011f6e3529a66b72 Mon Sep 17 00:00:00 2001 From: Orange-C Date: Thu, 17 Oct 2019 14:49:49 +0800 Subject: [PATCH 08/10] fix: fix ci --- babel.config.js | 27 +++++++++++++++++++++++++++ jest.config.js | 1 + package.json | 4 +--- scripts/config/getBabelConfig.js | 23 ++++++----------------- 4 files changed, 35 insertions(+), 20 deletions(-) create mode 100644 babel.config.js diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 0000000000..b8978a2687 --- /dev/null +++ b/babel.config.js @@ -0,0 +1,27 @@ +module.exports = function(api) { + // Cache the returned value forever and don't call this function again. + if (api) api.cache(true); + + return { + 'presets': [ + '@babel/preset-flow', + ['@babel/preset-env', { + 'loose': true, + }], + ['@babel/preset-react', { + 'pragma': 'createElement' + }] + ], + 'plugins': [ + '@babel/plugin-proposal-export-default-from', + ['@babel/plugin-proposal-class-properties', { 'loose': false }], + 'babel-plugin-transform-jsx-stylesheet', + ['@babel/plugin-proposal-decorators', { 'legacy': true }], + ], + 'ignore': [ + 'src/generator/templates', + '__mockc__', + 'dist' + ], + }; +}; diff --git a/jest.config.js b/jest.config.js index 57fea271c5..6234f26a74 100644 --- a/jest.config.js +++ b/jest.config.js @@ -18,6 +18,7 @@ module.exports = { '/__files__/', '/lib/', '/dist/', + '/es/', 'sfc-loader', 'atag', 'rax-cli/src/generator/' diff --git a/package.json b/package.json index de3986f5f8..8f67a0b1f8 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "babel-eslint": "10.0.1", "babel-jest": "23.6.0", "babel-loader": "8.0.4", + "babel-merge": "^3.0.0", "babel-plugin-transform-jsx-stylesheet": "0.6.5", "chalk": "^2.4.1", "chokidar": "^2.0.4", @@ -86,8 +87,5 @@ "commitizen": { "path": "./node_modules/cz-conventional-changelog" } - }, - "dependencies": { - "babel-merge": "^3.0.0" } } diff --git a/scripts/config/getBabelConfig.js b/scripts/config/getBabelConfig.js index a992d810f7..f93b69f14f 100644 --- a/scripts/config/getBabelConfig.js +++ b/scripts/config/getBabelConfig.js @@ -1,3 +1,7 @@ +const babelMerge = require('babel-merge'); + +const babelConfig = require('../../babel.config')(); + module.exports = function(ignoreModule) { const envOpt = { loose: true, @@ -7,24 +11,9 @@ module.exports = function(ignoreModule) { envOpt.modules = false; } - return { + return babelMerge(babelConfig, { presets: [ - '@babel/preset-flow', ['@babel/preset-env', envOpt], - ['@babel/preset-react', { - pragma: 'createElement' - }] - ], - plugins: [ - '@babel/plugin-proposal-export-default-from', - ['@babel/plugin-proposal-class-properties', { loose: false }], - 'babel-plugin-transform-jsx-stylesheet', - ['@babel/plugin-proposal-decorators', { legacy: true }], ], - ignore: [ - 'src/generator/templates', - '__mockc__', - 'dist' - ], - }; + }); }; From 118e3feff738d5928ec5e17767dfd776b93c58d0 Mon Sep 17 00:00:00 2001 From: yangfan <18767120422@163.com> Date: Thu, 17 Oct 2019 19:39:22 +0800 Subject: [PATCH 09/10] feat: update version --- packages/driver-dom/package.json | 2 +- packages/driver-universal/package.json | 2 +- packages/driver-weex/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/driver-dom/package.json b/packages/driver-dom/package.json index 6fb98ee599..36bc4d13b8 100644 --- a/packages/driver-dom/package.json +++ b/packages/driver-dom/package.json @@ -1,6 +1,6 @@ { "name": "driver-dom", - "version": "2.0.1", + "version": "2.0.2", "description": "DOM driver for Rax", "license": "BSD-3-Clause", "main": "lib/index.js", diff --git a/packages/driver-universal/package.json b/packages/driver-universal/package.json index f867d0c61b..78538b24a7 100644 --- a/packages/driver-universal/package.json +++ b/packages/driver-universal/package.json @@ -1,6 +1,6 @@ { "name": "driver-universal", - "version": "2.0.0", + "version": "2.0.1", "description": "Driver for Universal App.", "license": "BSD-3-Clause", "main": "lib/index.js", diff --git a/packages/driver-weex/package.json b/packages/driver-weex/package.json index ce92a2c576..533764e3cc 100644 --- a/packages/driver-weex/package.json +++ b/packages/driver-weex/package.json @@ -1,6 +1,6 @@ { "name": "driver-weex", - "version": "1.0.0", + "version": "1.0.1", "description": "Weex driver for Rax", "license": "BSD-3-Clause", "main": "lib/index.js", From ad742b9703837cac2cedf1f5068d15d0738a98bc Mon Sep 17 00:00:00 2001 From: yangfan <18767120422@163.com> Date: Thu, 17 Oct 2019 23:00:19 +0800 Subject: [PATCH 10/10] feat: tree shaking --- packages/driver-universal/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/driver-universal/package.json b/packages/driver-universal/package.json index 78538b24a7..e3942db419 100644 --- a/packages/driver-universal/package.json +++ b/packages/driver-universal/package.json @@ -5,6 +5,7 @@ "license": "BSD-3-Clause", "main": "lib/index.js", "module": "es/index.js", + "sideEffects": false, "repository": { "type": "git", "url": "git+https://github.com/alibaba/rax.git"