From 721469ea3c6eb44ca6c2b4921c4cb47e632a28f4 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Fri, 24 Jan 2020 10:08:55 +0100 Subject: [PATCH] chore: refactor build exports --- package.json | 10 +++++----- rollup.config.js | 25 +++++++++++++++---------- src/entries/iife.ts | 11 ----------- yarn.lock | 16 ++++++++-------- 4 files changed, 28 insertions(+), 34 deletions(-) delete mode 100644 src/entries/iife.ts diff --git a/package.json b/package.json index cd016836..28b9da7a 100644 --- a/package.json +++ b/package.json @@ -2,10 +2,10 @@ "name": "vue-router", "private": true, "version": "4.0.0-alpha.0", - "main": "src/index.ts", - "browser": "dist/vue-router.browser.esm.js", + "main": "dist/vue-router.cjs.js", + "browser": "dist/vue-router.esm.js", "unpkg": "dist/vue-router.js", - "module": "dist/vue-router.esm.js", + "module": "dist/vue-router.esm-bundler.js", "types": "dist/index.d.ts", "license": "MIT", "scripts": { @@ -29,7 +29,7 @@ "@types/webpack-env": "^1.15.0", "@vue/compiler-sfc": "^3.0.0-alpha.3", "axios": "^0.19.2", - "browserstack-local": "^1.4.4", + "browserstack-local": "^1.4.5", "chromedriver": "^79.0.0", "codecov": "^3.6.2", "consola": "^2.11.3", @@ -42,7 +42,7 @@ "nightwatch": "^1.3.2", "nightwatch-helpers": "^1.2.0", "prettier": "^1.19.1", - "rollup": "^1.29.0", + "rollup": "^1.29.1", "rollup-plugin-commonjs": "^10.1.0", "rollup-plugin-terser": "^5.2.0", "rollup-plugin-typescript2": "^0.25.3", diff --git a/rollup.config.js b/rollup.config.js index 3568bfdd..2580dd6c 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -34,18 +34,18 @@ function createEntry( if (minify) env = 'production' const isProductionBuild = process.env.__DEV__ === 'false' || env === 'production' - const isBundlerESMBuild = format === 'es' const config = { input, plugins: [ replace({ __VERSION__: JSON.stringify(pkg.version), - __DEV__: isBundlerESMBuild - ? // preserve to be handled by bundlers - `process.env.NODE_ENV !== 'production'` - : // hard coded dev/prod builds - !isProductionBuild, + __DEV__: + (format === 'es' && !isBrowser) || format === 'cjs' + ? // preserve to be handled by bundlers + `process.env.NODE_ENV !== 'production'` + : // hard coded dev/prod builds + !isProductionBuild, }), alias({ resolve: ['ts'], @@ -56,6 +56,11 @@ function createEntry( banner, file: 'dist/vue-router.other.js', format, + globals: { + '@vue/reactivity': 'Vue', + '@vue/runtime-core': 'Vue', + vue: 'Vue', + }, }, } @@ -94,9 +99,9 @@ function createEntry( config.plugins.push( terser({ module: format === 'es', - output: { - preamble: banner, - }, + // output: { + // preamble: banner, + // }, }) ) config.output.file = config.output.file.replace(/\.js$/i, '.min.js') @@ -110,7 +115,7 @@ export default [ createEntry({ format: 'iife' }), createEntry({ format: 'iife', minify: true }), createEntry({ format: 'cjs' }), + // TODO: prod vs env createEntry({ format: 'es' }), createEntry({ format: 'es', isBrowser: true }), - createEntry({ format: 'es', isBrowser: true, minify: true }), ] diff --git a/src/entries/iife.ts b/src/entries/iife.ts deleted file mode 100644 index 01d3ba68..00000000 --- a/src/entries/iife.ts +++ /dev/null @@ -1,11 +0,0 @@ -import * as VueRouter from '../index' - -// declare module '../index' { -// interface BackwardsCompatibleRouter { -// Router: BaseRouter -// install: typeof plugin -// HTML5History: HTML5History -// } -// } - -export default VueRouter diff --git a/yarn.lock b/yarn.lock index 4efd8e7b..28d82e83 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1475,10 +1475,10 @@ browserify-zlib@^0.2.0: dependencies: pako "~1.0.5" -browserstack-local@^1.4.4: - version "1.4.4" - resolved "https://registry.yarnpkg.com/browserstack-local/-/browserstack-local-1.4.4.tgz#993cf7860509e78eb3aa44888b3b5cb1aec60156" - integrity sha512-RAnOqO6/l1JVBLkhG2kfy8gUPpAXnWlgVN7VT7CrTkxpqKjBmZXy0jX6+3ES9XeY6l8yIKYbSOq3Jsg2ye9XUg== +browserstack-local@^1.4.5: + version "1.4.5" + resolved "https://registry.yarnpkg.com/browserstack-local/-/browserstack-local-1.4.5.tgz#115153ce1d08d58b7575ecf4381d54d10b42d2cf" + integrity sha512-0/VdSv2YVXmcnwBb64XThMvjM1HnZJnPdv7CUgQbC5y/N9Wsr0Fu+j1oknE9fC/VPx9CpoSC6CJ0kza42skMSA== dependencies: https-proxy-agent "^4.0.0" is-running "^2.1.0" @@ -6514,10 +6514,10 @@ rollup-pluginutils@^2.6.0, rollup-pluginutils@^2.8.1, rollup-pluginutils@^2.8.2: dependencies: estree-walker "^0.6.1" -rollup@^1.29.0: - version "1.29.0" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-1.29.0.tgz#6a1a79eea43ca9d3d79a90c15a1ceecedc72097b" - integrity sha512-V63Iz0dSdI5qPPN5HmCN6OBRzBFhMqNWcvwgq863JtSCTU6Vdvqq6S2fYle/dSCyoPrBkIP3EIr1RVs3HTRqqg== +rollup@^1.29.1: + version "1.29.1" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-1.29.1.tgz#8715d0a4ca439be3079f8095989ec8aa60f637bc" + integrity sha512-dGQ+b9d1FOX/gluiggTAVnTvzQZUEkCi/TwZcax7ujugVRHs0nkYJlV9U4hsifGEMojnO+jvEML2CJQ6qXgbHA== dependencies: "@types/estree" "*" "@types/node" "*" -- 2.47.3