Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use external @babel/runtime helpers #341

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"devDependencies": {
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/preset-react": "^7.12.5",
"@rollup/plugin-babel": "^5.2.1",
"@types/react": "^16.14.5",
"babel-loader": "^8.0.0",
Expand Down Expand Up @@ -79,6 +80,7 @@
"scrollspy"
],
"dependencies": {
"@babel/runtime": "^7.12.5",
"consolidated-events": "^1.1.0 || ^2.0.0",
"prop-types": "^15.0.0",
"react-is": "^17.0.1"
Expand Down
28 changes: 25 additions & 3 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import babel from '@rollup/plugin-babel';
import babel, { getBabelOutputPlugin } from '@rollup/plugin-babel';
import pkg from './package.json';

export default [
Expand All @@ -9,12 +9,34 @@ export default [
...Object.keys(pkg.peerDependencies),
],
output: [
{ file: pkg.main, format: 'cjs' },
{ file: pkg.module, format: 'es' },
{
file: pkg.main,
format: 'cjs',
plugins: [getBabelOutputPlugin({
presets: [['airbnb', {
modules: false,
runtimeVersion: '7.12.5',
runtimeHelpersUseESModules: false,
}]],
})],
},
{
file: pkg.module,
format: 'es',
plugins: [getBabelOutputPlugin({
presets: [['airbnb', {
modules: false,
runtimeVersion: '7.12.5',
runtimeHelpersUseESModules: true,
}]],
})],
},
],
plugins: [
babel({
babelrc: false,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this means that we probably want to remove the production section of the .babelrc. I can do that separately.

babelHelpers: 'bundled',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although don't we want to change this to runtime instead of using the getBabelOutputPlugin method? I'll try out an alternative approach now.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

presets: ['@babel/preset-react'],
exclude: ['node_modules/**'],
}),
],
Expand Down