Commit f81e5f4c authored by Luis Fernando Alvarez D's avatar Luis Fernando Alvarez D Committed by Tim Neutkens

Added babel-plugin-dynamic-import-node (#6811)

Replaces `import()` with `require` only for the testing environment.
parent 26a4eb82
......@@ -73,6 +73,8 @@ module.exports = (api: any, options: NextBabelPresetOptions = {}): BabelPreset =
plugins: [
require('babel-plugin-react-require'),
require('@babel/plugin-syntax-dynamic-import'),
// Transform dynamic import to require
isTest && require('babel-plugin-dynamic-import-node'),
require('./plugins/react-loadable-plugin'),
[require('@babel/plugin-proposal-class-properties'), options['class-properties'] || {}],
require('@babel/plugin-proposal-object-rest-spread'),
......
......@@ -54,6 +54,7 @@
"autodll-webpack-plugin": "0.4.2",
"babel-core": "7.0.0-bridge.0",
"babel-loader": "8.0.2",
"babel-plugin-dynamic-import-node": "2.2.0",
"babel-plugin-react-require": "3.0.0",
"babel-plugin-transform-react-remove-prop-types": "0.4.15",
"chalk": "2.4.2",
......
......@@ -116,8 +116,10 @@ export function runNextCommand (argv, options = {}) {
export function runNextCommandDev (argv, stdOut) {
const cwd = path.dirname(require.resolve('next/package'))
const env = { ...process.env, NODE_ENV: undefined }
return new Promise((resolve, reject) => {
const instance = spawn('node', ['dist/bin/next', ...argv], { cwd })
const instance = spawn('node', ['dist/bin/next', ...argv], { cwd, env })
function handleStdout (data) {
const message = data.toString()
......
......@@ -2532,6 +2532,13 @@ babel-messages@^6.23.0:
dependencies:
babel-runtime "^6.22.0"
babel-plugin-dynamic-import-node@2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.2.0.tgz#c0adfb07d95f4a4495e9aaac6ec386c4d7c2524e"
integrity sha512-fP899ELUnTaBcIzmrW7nniyqqdYWrWuJUyPWHxFa/c7r7hS6KC8FscNfLlBNIoPSc55kYMGEEKjPjJGCLbE1qA==
dependencies:
object.assign "^4.1.0"
babel-plugin-istanbul@^4.1.6:
version "4.1.6"
resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-4.1.6.tgz#36c59b2192efce81c5b378321b74175add1c9a45"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment