-
Notifications
You must be signed in to change notification settings - Fork 360
chore: convert bublé to babel for es2015 compilation #362
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
Changes from all commits
1cf6864
a77ca66
27d1a8a
ad59f1a
0633b7f
8f72b14
21a6c51
25e5be7
34717de
3483790
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,3 +12,4 @@ yarn.lock | |
| .vscode | ||
| .idea | ||
| .rts2* | ||
| sizes.csv | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,6 @@ import { rollup, watch } from 'rollup'; | |
| import commonjs from 'rollup-plugin-commonjs'; | ||
| import babel from 'rollup-plugin-babel'; | ||
| import nodeResolve from 'rollup-plugin-node-resolve'; | ||
| import buble from 'rollup-plugin-buble'; | ||
| import { terser } from 'rollup-plugin-terser'; | ||
| import alias from 'rollup-plugin-alias'; | ||
| import postcss from 'rollup-plugin-postcss'; | ||
|
|
@@ -18,7 +17,6 @@ import brotliSize from 'brotli-size'; | |
| import prettyBytes from 'pretty-bytes'; | ||
| import typescript from 'rollup-plugin-typescript2'; | ||
| import json from 'rollup-plugin-json'; | ||
| import flow from './lib/flow-plugin'; | ||
| import logError from './log-error'; | ||
| import { readFile, isDir, isFile, stdout, stderr } from './utils'; | ||
| import camelCase from 'camelcase'; | ||
|
|
@@ -529,7 +527,8 @@ function createConfig(options, entry, format, writeMeta) { | |
| compilerOptions: { | ||
| sourceMap: options.sourcemap, | ||
| declaration: true, | ||
| jsx: options.jsx, | ||
| jsx: 'react', | ||
| jsxFactory: options.jsx || 'h', | ||
| }, | ||
| }, | ||
| tsconfigOverride: { | ||
|
|
@@ -538,7 +537,6 @@ function createConfig(options, entry, format, writeMeta) { | |
| }, | ||
| }, | ||
| }), | ||
| !useTypescript && flow({ all: true, pretty: true }), | ||
| babel({ | ||
| babelrc: false, | ||
| configFile: false, | ||
|
|
@@ -551,18 +549,31 @@ function createConfig(options, entry, format, writeMeta) { | |
| ], | ||
| ], | ||
| }), | ||
| // Only used for async await | ||
| babel({ | ||
| // We mainly use bublé to transpile JS and only use babel to | ||
| // transpile down `async/await`. To prevent conflicts with user | ||
| // supplied configurations we set this option to false. Note | ||
| // that we never supported using custom babel configs anyway. | ||
| babelrc: false, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so if someone has a babelrc in their project dir it now gets included?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it's actually intentional. I'll add a few tests for it. This way people can add babel-plugin-macros and other plugins. So it will work with every codebase. I like microbundle so I don't have to configure rollup and such but would love babel configuration. We could put it under an option and warn people. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you add a Next.js solves this in a neat way imo. And in our case it could look something like this // .babelrc
{
"presets": "microbundle/babel",
"plugins": [
// my custom plugins
]
}
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah that would be ideal |
||
| configFile: false, | ||
| extensions: EXTENSIONS, | ||
| exclude: 'node_modules/**', | ||
| passPerPreset: true, // @see https://babeljs.io/docs/en/options#passperpreset | ||
| presets: [ | ||
| [ | ||
| '@babel/preset-env', | ||
| { | ||
| loose: true, | ||
| modules: false, | ||
| targets: | ||
| options.target === 'node' ? { node: '8' } : undefined, | ||
| exclude: ['transform-async-to-generator'], | ||
wardpeet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| ], | ||
| !useTypescript && ['@babel/preset-flow', { all: true }], | ||
| ].filter(Boolean), | ||
| plugins: [ | ||
| require.resolve('@babel/plugin-syntax-jsx'), | ||
| [ | ||
| require.resolve('@babel/plugin-transform-react-jsx'), | ||
| { | ||
| pragma: options.jsx || 'h', | ||
wardpeet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| pragmaFrag: options.jsxFragment || 'Fragment', | ||
| }, | ||
| ], | ||
| [ | ||
| require.resolve('babel-plugin-transform-replace-expressions'), | ||
| { replace: defines }, | ||
|
|
@@ -577,29 +588,6 @@ function createConfig(options, entry, format, writeMeta) { | |
| ], | ||
| ], | ||
| }), | ||
| buble({ | ||
| exclude: 'node_modules/**', | ||
| jsx: options.jsx || 'h', | ||
| objectAssign: options.assign || 'Object.assign', | ||
| transforms: { | ||
| dangerousForOf: true, | ||
| dangerousTaggedTemplateString: true, | ||
| }, | ||
| }), | ||
| // We should upstream this to rollup | ||
| // format==='cjs' && replace({ | ||
| // [`module.exports = ${rollupName};`]: '', | ||
| // [`var ${rollupName} =`]: 'module.exports =' | ||
| // }), | ||
| // This works for the general case, but could cause nasty scope bugs. | ||
| // format==='umd' && replace({ | ||
| // [`return ${rollupName};`]: '', | ||
| // [`var ${rollupName} =`]: 'return' | ||
| // }), | ||
| // format==='es' && replace({ | ||
| // [`export default ${rollupName};`]: '', | ||
| // [`var ${rollupName} =`]: 'export default' | ||
| // }), | ||
| options.compress !== false && [ | ||
| terser({ | ||
| sourcemap: true, | ||
|
|
||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.