Skip to content
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ yarn.lock
.vscode
.idea
.rts2*
sizes.csv
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
"@babel/core": "^7.4.4",
"@babel/plugin-proposal-class-properties": "7.4.4",
"@babel/plugin-syntax-jsx": "^7.2.0",
"@babel/plugin-transform-react-jsx": "^7.3.0",
"@babel/polyfill": "^7.4.4",
"@babel/preset-flow": "^7.0.0",
"asyncro": "^3.0.0",
"autoprefixer": "^9.5.1",
"babel-plugin-transform-async-to-promises": "^0.8.10",
Expand All @@ -61,10 +63,9 @@
"pretty-bytes": "^5.2.0",
"rollup": "^1.11.3",
"rollup-plugin-alias": "^1.5.1",
"rollup-plugin-babel": "^4.1.0-0",
"rollup-plugin-buble": "^0.19.4",
"rollup-plugin-bundle-size": "^1.0.3",
"rollup-plugin-commonjs": "^9.3.4",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-bundle-size": "^1.0.1",
"rollup-plugin-commonjs": "^9.0.0",
"rollup-plugin-es3": "^1.1.0",
"rollup-plugin-flow": "^1.1.1",
"rollup-plugin-json": "^4.0.0",
Expand All @@ -80,6 +81,7 @@
"devDependencies": {
"@babel/cli": "^7.4.4",
"@babel/node": "^7.2.2",
"@babel/plugin-proposal-throw-expressions": "^7.2.0",
"@babel/preset-env": "^7.4.4",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^24.8.0",
Expand All @@ -89,6 +91,7 @@
"eslint-config-developit": "^1.1.1",
"eslint-config-prettier": "^4.2.0",
"eslint-plugin-prettier": "^3.0.1",
"esm": "^3.2.22",
"fs-extra": "^7.0.1",
"husky": "^2.2.0",
"jest": "^24.8.0",
Expand Down
58 changes: 23 additions & 35 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -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: {
Expand All @@ -538,7 +537,6 @@ function createConfig(options, entry, format, writeMeta) {
},
},
}),
!useTypescript && flow({ all: true, pretty: true }),
babel({
babelrc: false,
configFile: false,
Expand All @@ -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,
Copy link
Collaborator

Choose a reason for hiding this comment

The 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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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.

Choose a reason for hiding this comment

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

If you add a .babelrc that would overwrite the default config right? In that case it would be nice to have a way to just extend the default config so you don't need to add preset-env again etc.

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
  ]
}

Copy link
Collaborator

Choose a reason for hiding this comment

The 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'],
},
],
!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',
pragmaFrag: options.jsxFragment || 'Fragment',
},
],
[
require.resolve('babel-plugin-transform-replace-expressions'),
{ replace: defines },
Expand All @@ -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,
Expand Down
12 changes: 0 additions & 12 deletions src/lib/flow-plugin.js

This file was deleted.

Loading