From 2214fbd2f9fec0cb88150e5addb6e13067791c8e Mon Sep 17 00:00:00 2001 From: jmfrancois Date: Mon, 25 Apr 2022 14:49:45 +0200 Subject: [PATCH] fix(dynamic cdn): handle package without varName --- .changeset/three-cups-taste.md | 5 +++++ fork/dynamic-cdn-webpack-plugin/src/index.js | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 .changeset/three-cups-taste.md diff --git a/.changeset/three-cups-taste.md b/.changeset/three-cups-taste.md new file mode 100644 index 00000000000..8b4bbd63481 --- /dev/null +++ b/.changeset/three-cups-taste.md @@ -0,0 +1,5 @@ +--- +'@talend/dynamic-cdn-webpack-plugin': patch +--- + +fix: handle package without varName diff --git a/fork/dynamic-cdn-webpack-plugin/src/index.js b/fork/dynamic-cdn-webpack-plugin/src/index.js index f4eae25dc5b..b206335b881 100644 --- a/fork/dynamic-cdn-webpack-plugin/src/index.js +++ b/fork/dynamic-cdn-webpack-plugin/src/index.js @@ -276,7 +276,9 @@ class DynamicCdnWebpackPlugin { async addModule(contextPath, modulePath, { env, isOptional = false }) { const isModuleExcluded = - this.exclude.includes(modulePath) || (this.only && !this.only.includes(modulePath)); + this.exclude.includes(modulePath) || + (this.only && !this.only.includes(modulePath)) || + modulePath.startsWith('@types/'); if (isModuleExcluded) { return false; } @@ -316,7 +318,7 @@ class DynamicCdnWebpackPlugin { if (!this.directDependencies[modulePath]) { this.directDependencies[modulePath] = this.modulesFromCdn[modulePath]; } - return this.modulesFromCdn[modulePath].var; + return this.modulesFromCdn[modulePath].var || true; } this.log( @@ -401,7 +403,7 @@ class DynamicCdnWebpackPlugin { this.modulesFromCdn[modulePath] = cdnConfig; this.directDependencies[modulePath] = cdnConfig; this.debug('\n✅', modulePath, version, `will be served by ${cdnConfig.url}`); - return cdnConfig.var; + return cdnConfig.var || true; } applyWebpackCore(compiler) {