From 5edceccd2b275afc80e02d269507a95f7d97d797 Mon Sep 17 00:00:00 2001 From: Jorge Antunes Date: Thu, 31 May 2018 14:46:20 +0100 Subject: [PATCH] remove explicit declaration of `babel-plugin-dynamic-import-node` (#63) * remove explicit declaration of `babel-plugin-dynamic-import-node` * use dynamic-import plugin only when needed --- .../babel-preset-dev-toolkit/index.js | 38 +++--- .../package-lock.json | 129 +++++++++--------- .../babel-preset-dev-toolkit/package.json | 4 +- 3 files changed, 91 insertions(+), 80 deletions(-) diff --git a/src/packages/babel-preset-dev-toolkit/index.js b/src/packages/babel-preset-dev-toolkit/index.js index e5420980..94174604 100644 --- a/src/packages/babel-preset-dev-toolkit/index.js +++ b/src/packages/babel-preset-dev-toolkit/index.js @@ -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'), + }, }, - }, - ], - ], + ], + ]), }; diff --git a/src/packages/babel-preset-dev-toolkit/package-lock.json b/src/packages/babel-preset-dev-toolkit/package-lock.json index 8309c801..7eac1f8a 100644 --- a/src/packages/babel-preset-dev-toolkit/package-lock.json +++ b/src/packages/babel-preset-dev-toolkit/package-lock.json @@ -1,9 +1,14 @@ { "name": "babel-preset-dev-toolkit", - "version": "1.0.3", + "version": "1.0.5", "lockfileVersion": 1, "requires": true, "dependencies": { + "@babel/plugin-syntax-dynamic-import": { + "version": "7.0.0-beta.34", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.0.0-beta.34.tgz", + "integrity": "sha512-uw+hEEeSl9PCNR//d3pGEwLHXSrZSPmlXZND9N/IsZfY36f7i+Pe140UWVxwzOcNCr4IKWyTlsu3FxisFsxfzw==" + }, "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", @@ -25,9 +30,9 @@ } }, "babel-core": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-core/-/babel-core-6.26.0.tgz", - "integrity": "sha1-rzL3izGm/O8RnIew/Y2XU/A6C7g=", + "version": "6.26.3", + "resolved": "https://registry.npmjs.org/babel-core/-/babel-core-6.26.3.tgz", + "integrity": "sha512-6jyFLuDmeidKmUEb3NM+/yawG0M2bDZ9Z1qbZP59cyHLz8kYGKYwpJP0UwUKKUiTRNvxfLesJnTedqczP7cTDA==", "requires": { "babel-code-frame": "6.26.0", "babel-generator": "6.26.1", @@ -42,7 +47,7 @@ "convert-source-map": "1.5.1", "debug": "2.6.9", "json5": "0.5.1", - "lodash": "4.17.5", + "lodash": "4.17.10", "minimatch": "3.0.4", "path-is-absolute": "1.0.1", "private": "0.1.8", @@ -60,7 +65,7 @@ "babel-types": "6.26.0", "detect-indent": "4.0.0", "jsesc": "1.3.0", - "lodash": "4.17.5", + "lodash": "4.17.10", "source-map": "0.5.7", "trim-right": "1.0.1" }, @@ -111,7 +116,7 @@ "babel-helper-function-name": "6.24.1", "babel-runtime": "6.26.0", "babel-types": "6.26.0", - "lodash": "4.17.5" + "lodash": "4.17.10" } }, "babel-helper-explode-assignable-expression": { @@ -170,7 +175,7 @@ "requires": { "babel-runtime": "6.26.0", "babel-types": "6.26.0", - "lodash": "4.17.5" + "lodash": "4.17.10" } }, "babel-helper-remap-async-to-generator": { @@ -224,11 +229,13 @@ } }, "babel-plugin-dynamic-import-node": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-1.2.0.tgz", - "integrity": "sha512-yeDwKaLgGdTpXL7RgGt5r6T4LmnTza/hUn5Ul8uZSGGMtEjYo13Nxai7SQaGCTEzUtg9Zq9qJn0EjEr7SeSlTQ==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-1.1.0.tgz", + "integrity": "sha512-tTfZbM9Ecwj3GK50mnPrUpinTwA4xXmDiQGCk/aBYbvl1+X8YqldK86wZ1owVJ4u3mrKbRlXMma80J18qwiaTQ==", "requires": { - "babel-plugin-syntax-dynamic-import": "6.18.0" + "babel-plugin-syntax-dynamic-import": "6.18.0", + "babel-template": "6.26.0", + "babel-types": "6.26.0" } }, "babel-plugin-module-resolver": { @@ -240,7 +247,7 @@ "glob": "7.1.2", "pkg-up": "2.0.0", "reselect": "3.0.1", - "resolve": "1.6.0" + "resolve": "1.7.1" } }, "babel-plugin-syntax-async-functions": { @@ -304,6 +311,14 @@ "babel-template": "6.26.0" } }, + "babel-plugin-transform-dynamic-import": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-dynamic-import/-/babel-plugin-transform-dynamic-import-2.0.0.tgz", + "integrity": "sha512-Ko29hMq0MMsQngUZncrCjIejjETmOJZqaxvBa1hEXK/XB1uNq3Yt0GG5Jl0BRqVyh2m7WhjnXA98IHxolUoX+w==", + "requires": { + "@babel/plugin-syntax-dynamic-import": "7.0.0-beta.34" + } + }, "babel-plugin-transform-es2015-arrow-functions": { "version": "6.22.0", "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz", @@ -329,7 +344,7 @@ "babel-template": "6.26.0", "babel-traverse": "6.26.0", "babel-types": "6.26.0", - "lodash": "4.17.5" + "lodash": "4.17.10" } }, "babel-plugin-transform-es2015-classes": { @@ -645,7 +660,7 @@ "babel-plugin-transform-es2015-unicode-regex": "6.24.1", "babel-plugin-transform-exponentiation-operator": "6.24.1", "babel-plugin-transform-regenerator": "6.26.0", - "browserslist": "3.2.7", + "browserslist": "3.2.8", "invariant": "2.2.4", "semver": "5.5.0" } @@ -691,16 +706,6 @@ "babel-preset-react": "6.24.1" }, "dependencies": { - "babel-plugin-dynamic-import-node": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-1.1.0.tgz", - "integrity": "sha512-tTfZbM9Ecwj3GK50mnPrUpinTwA4xXmDiQGCk/aBYbvl1+X8YqldK86wZ1owVJ4u3mrKbRlXMma80J18qwiaTQ==", - "requires": { - "babel-plugin-syntax-dynamic-import": "6.18.0", - "babel-template": "6.26.0", - "babel-types": "6.26.0" - } - }, "babel-preset-env": { "version": "1.6.1", "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.1.tgz", @@ -743,8 +748,8 @@ "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.11.3.tgz", "integrity": "sha512-yWu5cXT7Av6mVwzWc8lMsJMHWn4xyjSuGYi4IozbVTLUOEYPSagUB8kiMDUHA1fS3zjr8nkxkn9jdvug4BBRmA==", "requires": { - "caniuse-lite": "1.0.30000839", - "electron-to-chromium": "1.3.45" + "caniuse-lite": "1.0.30000847", + "electron-to-chromium": "1.3.48" } } } @@ -754,11 +759,11 @@ "resolved": "https://registry.npmjs.org/babel-register/-/babel-register-6.26.0.tgz", "integrity": "sha1-btAhFz4vy0htestFxgCahW9kcHE=", "requires": { - "babel-core": "6.26.0", + "babel-core": "6.26.3", "babel-runtime": "6.26.0", - "core-js": "2.5.4", + "core-js": "2.5.7", "home-or-tmp": "2.0.0", - "lodash": "4.17.5", + "lodash": "4.17.10", "mkdirp": "0.5.1", "source-map-support": "0.4.18" } @@ -768,7 +773,7 @@ "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", "requires": { - "core-js": "2.5.4", + "core-js": "2.5.7", "regenerator-runtime": "0.11.1" } }, @@ -781,7 +786,7 @@ "babel-traverse": "6.26.0", "babel-types": "6.26.0", "babylon": "6.18.0", - "lodash": "4.17.5" + "lodash": "4.17.10" } }, "babel-traverse": { @@ -797,7 +802,7 @@ "debug": "2.6.9", "globals": "9.18.0", "invariant": "2.2.4", - "lodash": "4.17.5" + "lodash": "4.17.10" } }, "babel-types": { @@ -807,7 +812,7 @@ "requires": { "babel-runtime": "6.26.0", "esutils": "2.0.2", - "lodash": "4.17.5", + "lodash": "4.17.10", "to-fast-properties": "1.0.3" } }, @@ -831,18 +836,18 @@ } }, "browserslist": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-3.2.7.tgz", - "integrity": "sha512-oYVLxFVqpX9uMhOIQBLtZL+CX4uY8ZpWcjNTaxyWl5rO8yA9SSNikFnAfvk8J3P/7z3BZwNmEqFKaJoYltj3MQ==", + "version": "3.2.8", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-3.2.8.tgz", + "integrity": "sha512-WHVocJYavUwVgVViC0ORikPHQquXwVh939TaelZ4WDqpWgTX/FsGhl/+P4qBUAGcRvtOgDgC+xftNWWp2RUTAQ==", "requires": { - "caniuse-lite": "1.0.30000839", - "electron-to-chromium": "1.3.45" + "caniuse-lite": "1.0.30000847", + "electron-to-chromium": "1.3.48" } }, "caniuse-lite": { - "version": "1.0.30000839", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000839.tgz", - "integrity": "sha512-gJZIfmkuy84agOeAZc7WJOexZhisZaBSFk96gkGM6TkH7+1mBfr/MSPnXC8lO0g7guh/ucbswYjruvDbzc6i0g==" + "version": "1.0.30000847", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000847.tgz", + "integrity": "sha512-Weo+tRtVWcN2da782Ebx/27hFNEb+KP+uP6tdqAa+2S5bp1zOJhVH9tEpDygagrfvU4QjeuPwi/5VGsgT4SLaA==" }, "chalk": { "version": "1.1.3", @@ -867,9 +872,9 @@ "integrity": "sha1-uCeAl7m8IpNl3lxiz1/K7YtVmeU=" }, "core-js": { - "version": "2.5.4", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.4.tgz", - "integrity": "sha1-8si/GB8qgLkvNgEhQpzmOi8K6uA=" + "version": "2.5.7", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.7.tgz", + "integrity": "sha512-RszJCAxg/PP6uzXVXL6BsxSXx/B05oJAQ2vkJRjyjrEcNVycaqOmNb5OTxZPE3xa5gwZduqza6L9JOCenh/Ecw==" }, "debug": { "version": "2.6.9", @@ -888,9 +893,9 @@ } }, "electron-to-chromium": { - "version": "1.3.45", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.45.tgz", - "integrity": "sha1-RYrBscXHYM6IEaFtK/vZfsMLr7g=" + "version": "1.3.48", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.48.tgz", + "integrity": "sha1-07DYWTgUBE4JLs4hCPw6ya6kuQA=" }, "escape-string-regexp": { "version": "1.0.5", @@ -1009,7 +1014,7 @@ "resolved": "https://registry.npmjs.org/jsx-control-statements/-/jsx-control-statements-3.2.8.tgz", "integrity": "sha512-RUHKXNAA4RiBijHIrLuyIiA6E0oLN6tvtCLcOzzzhVAjlcsLHQc0IbVQF0XGtlhsi6a6+HFwvo0duKVzzxuRcg==", "requires": { - "babel-core": "6.26.0", + "babel-core": "6.26.3", "babel-plugin-syntax-jsx": "6.18.0" } }, @@ -1023,9 +1028,9 @@ } }, "lodash": { - "version": "4.17.5", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==" + "version": "4.17.10", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", + "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==" }, "loose-envify": { "version": "1.3.1", @@ -1129,9 +1134,9 @@ } }, "prettier": { - "version": "1.12.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.12.1.tgz", - "integrity": "sha1-wa0g6APndJ+vkFpAnSNn4Gu+cyU=", + "version": "1.13.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.13.3.tgz", + "integrity": "sha512-CIWJNU+cFFdeA0GJSzzFkxiq2WuMvWZMlz6cV/EXhPlRnI3esSFMh+lNmyZ8z/X8O8C1U60Sc8puXALj4/WmZw==", "dev": true }, "private": { @@ -1140,9 +1145,9 @@ "integrity": "sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==" }, "regenerate": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.3.3.tgz", - "integrity": "sha512-jVpo1GadrDAK59t/0jRx5VxYWQEDkkEKi6+HjE3joFVLfDOh9Xrdh0dF1eSq+BI/SwvTQ44gSscJ8N5zYL61sg==" + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.0.tgz", + "integrity": "sha512-1G6jJVDWrt0rK99kBjvEtziZNCICAuvIPkSiUFIQxVP06RCVpq3dmDo2oi6ABpYaDYaTRr67BEhL8r1wgEZZKg==" }, "regenerator-runtime": { "version": "0.11.1", @@ -1164,7 +1169,7 @@ "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-2.0.0.tgz", "integrity": "sha1-SdA4g3uNz4v6W5pCE5k45uoq4kA=", "requires": { - "regenerate": "1.3.3", + "regenerate": "1.4.0", "regjsgen": "0.2.0", "regjsparser": "0.1.5" } @@ -1196,9 +1201,9 @@ "integrity": "sha1-79qpjqdFEyTQkrKyFjpqHXqaIUc=" }, "resolve": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.6.0.tgz", - "integrity": "sha512-mw7JQNu5ExIkcw4LPih0owX/TZXjD/ZUF/ZQ/pDnkw3ZKhDcZZw5klmBlj6gVMwjQ3Pz5Jgu7F3d0jcDVuEWdw==", + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz", + "integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==", "requires": { "path-parse": "1.0.5" } diff --git a/src/packages/babel-preset-dev-toolkit/package.json b/src/packages/babel-preset-dev-toolkit/package.json index 37115f4d..eed9081d 100644 --- a/src/packages/babel-preset-dev-toolkit/package.json +++ b/src/packages/babel-preset-dev-toolkit/package.json @@ -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": { @@ -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"