From 07365ca12e33c2371cc68b6fae3336dd188a6374 Mon Sep 17 00:00:00 2001 From: austaras Date: Wed, 11 Mar 2020 03:00:51 +0800 Subject: [PATCH] fix: check for entryPoint to have entryModule fixes #56 --- examples/typescript-plain/webpack.config.js | 4 ++++ src/babel-target.ts | 3 +++ src/babel.multi.target.html.updater.ts | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/examples/typescript-plain/webpack.config.js b/examples/typescript-plain/webpack.config.js index 0b96cdd..3ee500c 100644 --- a/examples/typescript-plain/webpack.config.js +++ b/examples/typescript-plain/webpack.config.js @@ -15,6 +15,10 @@ module.exports = { 'main': './src/entry.ts', }, + optimization: { + runtimeChunk: 'single', + }, + module: { rules: [ { diff --git a/src/babel-target.ts b/src/babel-target.ts index d448bde..6fbd160 100644 --- a/src/babel-target.ts +++ b/src/babel-target.ts @@ -162,6 +162,9 @@ export class BabelTarget implements BabelTargetInfo { } public static getTargetFromEntrypoint(entrypoint: Entrypoint): BabelTarget { + if (!entrypoint.runtimeChunk.hasEntryModule()) { + return undefined + } return BabelTarget.getTargetFromModule(entrypoint.runtimeChunk.entryModule) } diff --git a/src/babel.multi.target.html.updater.ts b/src/babel.multi.target.html.updater.ts index b8ddf74..7d149eb 100644 --- a/src/babel.multi.target.html.updater.ts +++ b/src/babel.multi.target.html.updater.ts @@ -46,6 +46,10 @@ export class BabelMultiTargetHtmlUpdater implements Plugin { } const target = targets[0] + if (target === undefined) { + return + } + if (target.esModule) { tag.attributes.type = 'module' return