Skip to content

Commit

Permalink
remove explicit declaration of babel-plugin-dynamic-import-node (#63)
Browse files Browse the repository at this point in the history
* remove explicit declaration of `babel-plugin-dynamic-import-node`

* use dynamic-import plugin only when needed
  • Loading branch information
stoikerty authored May 31, 2018
1 parent 15e2951 commit 5edcecc
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 80 deletions.
38 changes: 22 additions & 16 deletions src/packages/babel-preset-dev-toolkit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,27 @@ module.exports = {
// Use create-react-app default
require.resolve('babel-preset-react-app'),
],
plugins: [
// Support dynamic `import()`-statement
require.resolve('babel-plugin-dynamic-import-node'),
// Sane if-statements for React
require.resolve('jsx-control-statements'),
// Allow root-relative imports for client & server
[
require.resolve('babel-plugin-module-resolver'),
{
// using `process.cwd` makes it also work with `import()`
root: ['./src'],
alias: {
src: path.resolve(process.cwd(), 'src'),
plugins: []
.concat(
env !== 'test'
? // Support dynamic `import()`-statement everywhere
[require.resolve('babel-plugin-transform-dynamic-import')]
: // Ignore transform-dynamic-import in `test` env since `babel-preset-react-app` already includes it
[]
)
.concat([
// Sane if-statements for React
require.resolve('jsx-control-statements'),
// Allow root-relative imports for client & server
[
require.resolve('babel-plugin-module-resolver'),
{
// using `process.cwd` makes it also work with `import()`
root: ['./src'],
alias: {
src: path.resolve(process.cwd(), 'src'),
},
},
},
],
],
],
]),
};
129 changes: 67 additions & 62 deletions src/packages/babel-preset-dev-toolkit/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/packages/babel-preset-dev-toolkit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "babel-preset-dev-toolkit",
"version": "1.0.3",
"version": "1.0.5",
"description": "Uses create-react-app default, adds sane if-statements & root-relative imports",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -29,8 +29,8 @@
"author": "Jorge Antunes @stoikerty",
"license": "MIT",
"dependencies": {
"babel-plugin-dynamic-import-node": "^1.2.0",
"babel-plugin-module-resolver": "^3.1.0",
"babel-plugin-transform-dynamic-import": "^2.0.0",
"babel-preset-env": "^1.7.0",
"babel-preset-react-app": "^3.1.1",
"jsx-control-statements": "^3.2.8"
Expand Down

0 comments on commit 5edcecc

Please sign in to comment.