Commit dbd6f515 authored by Vlad Nicula's avatar Vlad Nicula Committed by Tim Neutkens

Fix dynamic import in non webpack env regression #3345 (#4208)

Just in case #3345 was a regression and nextjs should still support non webpack node envs for testing.
parent 9b88eef8
...@@ -16,6 +16,16 @@ const TYPE_IMPORT = 'Import' ...@@ -16,6 +16,16 @@ const TYPE_IMPORT = 'Import'
const buildImport = (args) => (template(` const buildImport = (args) => (template(`
( (
typeof require.resolveWeak !== 'function' ?
new (require('next/dynamic').SameLoopPromise)((resolve, reject) => {
eval('require.ensure = function (deps, callback) { callback(require) }')
require.ensure([], (require) => {
let m = require(SOURCE)
m.__webpackChunkName = '${args.name}.js'
resolve(m);
}, 'chunks/${args.name}.js');
})
:
new (require('next/dynamic').SameLoopPromise)((resolve, reject) => { new (require('next/dynamic').SameLoopPromise)((resolve, reject) => {
const weakId = require.resolveWeak(SOURCE) const weakId = require.resolveWeak(SOURCE)
try { try {
......
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