mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
allow disabling async importer
This commit is contained in:
parent
ad4fc18ab8
commit
ee27e3b5fe
@ -20,7 +20,6 @@ async function main () {
|
||||
buildDir: '',
|
||||
targets: [],
|
||||
nuxt: 2,
|
||||
dynamicImporter: undefined,
|
||||
importSync: "require('../server/' + chunkId)",
|
||||
importAsync: "Promise.resolve(require('../server/' + chunkId))",
|
||||
target: process.argv[3] && process.argv[3][0] !== '-' ? process.argv[3] : null,
|
||||
@ -51,10 +50,8 @@ async function main () {
|
||||
consola.info('Generated', prettyPath(htmlTemplateFileJS))
|
||||
|
||||
// Collect dynamic chunks
|
||||
if (!config.dynamicImporter) {
|
||||
consola.info('Collecting dynamic chunks...')
|
||||
config.dynamicImporter = await createDynamicImporter(resolve(config.buildDir, 'dist/server'))
|
||||
}
|
||||
consola.info('Collecting dynamic chunks...')
|
||||
const dynamicImporter = await createDynamicImporter(resolve(config.buildDir, 'dist/server'))
|
||||
|
||||
// Bundle for each target
|
||||
for (let target of config.targets) {
|
||||
@ -72,7 +69,8 @@ async function main () {
|
||||
const ctx: any = defu(
|
||||
target,
|
||||
config,
|
||||
tryImport(__dirname, `./targets/${target.target}`) || tryImport(config.rootDir, target.target)
|
||||
tryImport(__dirname, `./targets/${target.target}`) || tryImport(config.rootDir, target.target),
|
||||
{ dynamicImporter }
|
||||
)
|
||||
|
||||
const hooks = new Hookable()
|
||||
|
@ -70,7 +70,7 @@ export const getRollupConfig = (config) => {
|
||||
if (config.dynamicImporter) {
|
||||
options.output.intro += config.dynamicImporter(config.importSync, config.importAsync)
|
||||
} else {
|
||||
options.output.intro += 'const requireDynamic = require;'
|
||||
options.output.intro += `const requireDynamic = (chunkId) => ${config.importSync}`
|
||||
}
|
||||
options.plugins.push(replace({ values: { 'require("./" +': 'requireDynamic(' }, delimiters: ['', ''] }))
|
||||
|
||||
|
@ -2,6 +2,7 @@ import consola from 'consola'
|
||||
|
||||
export default {
|
||||
entry: require.resolve('./entry'),
|
||||
dynamicImporter: false,
|
||||
hooks: {
|
||||
'rollup:done' (_ctx) {
|
||||
consola.info('Run `vercel deploy` to deploy!')
|
||||
|
Loading…
Reference in New Issue
Block a user