mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Just in case #3345 was a regression and nextjs should still support non webpack node envs for testing.
This commit is contained in:
parent
9b88eef897
commit
dbd6f515a0
|
@ -16,23 +16,33 @@ const TYPE_IMPORT = 'Import'
|
|||
|
||||
const buildImport = (args) => (template(`
|
||||
(
|
||||
new (require('next/dynamic').SameLoopPromise)((resolve, reject) => {
|
||||
const weakId = require.resolveWeak(SOURCE)
|
||||
try {
|
||||
const weakModule = __webpack_require__(weakId)
|
||||
return resolve(weakModule)
|
||||
} catch (err) {}
|
||||
|
||||
require.ensure([], (require) => {
|
||||
try {
|
||||
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}'
|
||||
resolve(m)
|
||||
} catch(error) {
|
||||
reject(error)
|
||||
}
|
||||
}, 'chunks/${args.name}');
|
||||
})
|
||||
m.__webpackChunkName = '${args.name}.js'
|
||||
resolve(m);
|
||||
}, 'chunks/${args.name}.js');
|
||||
})
|
||||
:
|
||||
new (require('next/dynamic').SameLoopPromise)((resolve, reject) => {
|
||||
const weakId = require.resolveWeak(SOURCE)
|
||||
try {
|
||||
const weakModule = __webpack_require__(weakId)
|
||||
return resolve(weakModule)
|
||||
} catch (err) {}
|
||||
|
||||
require.ensure([], (require) => {
|
||||
try {
|
||||
let m = require(SOURCE)
|
||||
m.__webpackChunkName = '${args.name}'
|
||||
resolve(m)
|
||||
} catch(error) {
|
||||
reject(error)
|
||||
}
|
||||
}, 'chunks/${args.name}');
|
||||
})
|
||||
)
|
||||
`))
|
||||
|
||||
|
|
Loading…
Reference in a new issue