From edfc7f054f1f6f56f48265e2491ac8104baa4feb Mon Sep 17 00:00:00 2001 From: Vladislav Moiseev Date: Sun, 9 Aug 2020 00:05:41 +0400 Subject: [PATCH] Migrate from rollup-plugin-babel to @rollup/plugin-babel BREAKING: requires Node 10+ - was getting a warning on install: - "npm WARN deprecated rollup-plugin-babel@4.4.0: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-babel." - c.f. https://github.com/rollup/plugins/blob/master/packages/babel/CHANGELOG.md#breaking-changes - `babelPlugin.custom` is now a separate export, `createBabelInputPluginFactory` - `babelHelpers: 'bundled'` was added - this is the default and backward-compatible with 4.x, but they recommended explicitly configuring it as such - c.f. https://github.com/rollup/plugins/blob/master/packages/babel/CHANGELOG.md#v510 - typings have been added to the package directly, no need to declare module to workaround lack of typings anymore - remove old commented out line referring to rollup-plugin-babel as well Co-Authored-By: Anton Gilgur --- package.json | 2 +- src/babelPluginTsdx.ts | 4 ++-- src/createRollupConfig.ts | 2 +- src/env.d.ts | 1 - yarn.lock | 30 +++++++++++++++--------------- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index d14567965..4e31bbcaa 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "@babel/helper-module-imports": "^7.0.0", "@babel/plugin-proposal-class-properties": "^7.4.4", "@babel/preset-env": "^7.11.0", + "@rollup/plugin-babel": "^5.1.0", "@rollup/plugin-commonjs": "^11.0.0", "@rollup/plugin-json": "^4.0.0", "@rollup/plugin-node-resolve": "^7.1.0", @@ -86,7 +87,6 @@ "progress-estimator": "^0.2.2", "regenerator-runtime": "^0.13.7", "rollup": "^1.32.1", - "rollup-plugin-babel": "^4.3.2", "rollup-plugin-sourcemaps": "^0.5.0", "rollup-plugin-terser": "^5.1.2", "rollup-plugin-typescript2": "^0.26.0", diff --git a/src/babelPluginTsdx.ts b/src/babelPluginTsdx.ts index 9458d2d90..525d60934 100644 --- a/src/babelPluginTsdx.ts +++ b/src/babelPluginTsdx.ts @@ -1,5 +1,5 @@ import { createConfigItem } from '@babel/core'; -import babelPlugin from 'rollup-plugin-babel'; +import { createBabelInputPluginFactory } from '@rollup/plugin-babel'; import merge from 'lodash.merge'; export const isTruthy = (obj?: any) => { @@ -47,7 +47,7 @@ export const createConfigItems = (type: any, items: any[]) => { }); }; -export const babelPluginTsdx = babelPlugin.custom(() => ({ +export const babelPluginTsdx = createBabelInputPluginFactory(() => ({ // Passed the plugin options. options({ custom: customOptions, ...pluginOptions }: any) { return { diff --git a/src/createRollupConfig.ts b/src/createRollupConfig.ts index 0267dc031..6558519d6 100644 --- a/src/createRollupConfig.ts +++ b/src/createRollupConfig.ts @@ -3,7 +3,6 @@ import { paths } from './constants'; import { RollupOptions } from 'rollup'; import { terser } from 'rollup-plugin-terser'; import { DEFAULT_EXTENSIONS } from '@babel/core'; -// import babel from 'rollup-plugin-babel'; import commonjs from '@rollup/plugin-commonjs'; import json from '@rollup/plugin-json'; import replace from '@rollup/plugin-replace'; @@ -193,6 +192,7 @@ export async function createRollupConfig( extractErrors: opts.extractErrors, format: opts.format, }, + babelHelpers: 'bundled', }), opts.env !== undefined && replace({ diff --git a/src/env.d.ts b/src/env.d.ts index 0785badc2..fe32705b6 100644 --- a/src/env.d.ts +++ b/src/env.d.ts @@ -11,7 +11,6 @@ declare module '@babel/core' { } // Rollup plugins -declare module 'rollup-plugin-babel'; declare module 'rollup-plugin-terser'; declare module 'babel-traverse'; declare module 'babylon'; diff --git a/yarn.lock b/yarn.lock index 8b08e272c..227cb54d1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -156,7 +156,7 @@ dependencies: "@babel/types" "^7.11.0" -"@babel/helper-module-imports@^7.0.0", "@babel/helper-module-imports@^7.10.4": +"@babel/helper-module-imports@^7.0.0", "@babel/helper-module-imports@^7.10.4", "@babel/helper-module-imports@^7.7.4": version "7.10.4" resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.10.4.tgz#4c5c54be04bd31670a7382797d75b9fa2e5b5620" integrity sha512-nEQJHqYavI217oD9+s5MUBzk6x1IlvoS9WTPfgG43CbMEeStE0v+r+TucWdx8KFGowPGvyOkDT9+7DHedIDnVw== @@ -1063,6 +1063,14 @@ "@types/yargs" "^15.0.0" chalk "^3.0.0" +"@rollup/plugin-babel@^5.1.0": + version "5.1.0" + resolved "https://registry.yarnpkg.com/@rollup/plugin-babel/-/plugin-babel-5.1.0.tgz#ad8b5803fa6e1feb0f168984edc040b90d966450" + integrity sha512-zXBEYmfiLAMvB+ZBa6m/q9hsQYAq1sUFdjuP1F6C2pf6uQcpHwAWQveZgzS63zXdKPUYHD3Dr7BhjCqcr0bbLw== + dependencies: + "@babel/helper-module-imports" "^7.7.4" + "@rollup/pluginutils" "^3.0.8" + "@rollup/plugin-commonjs@^11.0.0": version "11.0.0" resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-11.0.0.tgz#a6675e56094ac9c797c19a3986378289396a9dd5" @@ -1100,14 +1108,14 @@ magic-string "^0.25.2" rollup-pluginutils "^2.6.0" -"@rollup/pluginutils@^3.0.0", "@rollup/pluginutils@^3.0.1", "@rollup/pluginutils@^3.0.6": - version "3.0.9" - resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.0.9.tgz#aa6adca2c45e5a1b950103a999e3cddfe49fd775" - integrity sha512-TLZavlfPAZYI7v33wQh4mTP6zojne14yok3DNSLcjoG/Hirxfkonn6icP5rrNWRn8nZsirJBFFpijVOJzkUHDg== +"@rollup/pluginutils@^3.0.0", "@rollup/pluginutils@^3.0.1", "@rollup/pluginutils@^3.0.6", "@rollup/pluginutils@^3.0.8": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b" + integrity sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg== dependencies: "@types/estree" "0.0.39" estree-walker "^1.0.1" - micromatch "^4.0.2" + picomatch "^2.2.2" "@samverschueren/stream-to-observable@^0.3.0": version "0.3.0" @@ -6305,7 +6313,7 @@ performance-now@^2.1.0: resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns= -picomatch@^2.0.4, picomatch@^2.0.5: +picomatch@^2.0.4, picomatch@^2.0.5, picomatch@^2.2.2: version "2.2.2" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad" integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg== @@ -7231,14 +7239,6 @@ rimraf@^3.0.0: dependencies: glob "^7.1.3" -rollup-plugin-babel@^4.3.2: - version "4.3.3" - resolved "https://registry.yarnpkg.com/rollup-plugin-babel/-/rollup-plugin-babel-4.3.3.tgz#7eb5ac16d9b5831c3fd5d97e8df77ba25c72a2aa" - integrity sha512-tKzWOCmIJD/6aKNz0H1GMM+lW1q9KyFubbWzGiOG540zxPPifnEAHTZwjo0g991Y+DyOZcLqBgqOdqazYE5fkw== - dependencies: - "@babel/helper-module-imports" "^7.0.0" - rollup-pluginutils "^2.8.1" - rollup-plugin-postcss@^2.5.0: version "2.5.0" resolved "https://registry.yarnpkg.com/rollup-plugin-postcss/-/rollup-plugin-postcss-2.5.0.tgz#54ef2487cda498d8bca69aaca3b55b30dee0106b"