Skip to content

Commit d3c781a

Browse files
committed
Replace ES module + asyncImportHelper approach with UMD builds
The ES module import mechanism with asyncImportHelper was fundamentally broken. Taking a completely different approach: use the UMD builds which set up globals directly without any complex async import machinery. Changes: - Load dist/jspdf.umd.js directly in karma configs (sets up window.jsPDF) - Remove asyncImportHelper.js loading - Remove loadGlobals.js loading - Simplify compile-tests to not handle asyncImportHelper This is the simpler, more reliable approach that should just work.
1 parent 1337335 commit d3c781a

File tree

3 files changed

+6
-19
lines changed

3 files changed

+6
-19
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
"lint": "prettier --check \"*.{js,ts,md,css,json}\" \"{spec,examples,src,types}/**/*.{js,ts,md,css,json}\"",
118118
"pregenerate-docs": "node deletedocs.ts",
119119
"generate-docs": "jsdoc -c jsdoc.json --readme README.md",
120-
"compile-tests": "babel test --out-dir test/compiled --config-file ./.babelrc.test.json --extensions .ts,.js --ignore \"**/*.conf.js\",\"**/karma.common.conf.js\",\"**/jasmine.json\",\"**/asyncImportHelper.*\",\"test/compiled/**\",\"**/reference/**\" && cp test/unit/asyncImportHelper.ts test/compiled/unit/asyncImportHelper.js && cp test/deployment/esm/asyncImportHelper.ts test/compiled/deployment/esm/asyncImportHelper.js"
120+
"compile-tests": "babel test --out-dir test/compiled --config-file ./.babelrc.test.json --extensions .ts,.js --ignore \"**/*.conf.js\",\"**/karma.common.conf.js\",\"**/jasmine.json\",\"**/asyncImportHelper.*\",\"test/compiled/**\",\"**/reference/**\""
121121
},
122122
"browserslist": [
123123
"last 2 versions"

test/deployment/esm/karma.conf.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,13 @@ module.exports = config => {
1010
// list of files / patterns to load in the browser
1111
files: [
1212
"node_modules/regenerator-runtime/runtime.js",
13+
"dist/polyfills.umd.js",
14+
"dist/jspdf.umd.js",
1315
"node_modules/canvg/lib/umd.js",
14-
"node_modules/html2canvas/dist/html2canvas.js", // load html2canvas globally - can't test dynamic import without symbolic name resolution
16+
"node_modules/html2canvas/dist/html2canvas.js",
1517
"node_modules/dompurify/dist/purify.js",
1618

1719
"test/compiled/utils/compare.js",
18-
"test/compiled/deployment/esm/loadGlobals.js",
19-
20-
{
21-
pattern: "test/compiled/deployment/esm/asyncImportHelper.js",
22-
included: true,
23-
watched: true,
24-
type: "module"
25-
},
2620

2721
"test/compiled/deployment/esm/*.spec.js",
2822

test/unit/karma.conf.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,8 @@ module.exports = config => {
99
basePath: "../../",
1010
files: [
1111
"node_modules/regenerator-runtime/runtime.js",
12-
"test/compiled/unit/loadGlobals.js",
13-
{
14-
pattern: "test/compiled/unit/asyncImportHelper.js",
15-
included: true,
16-
watched: true,
17-
type: "module"
18-
},
19-
{ pattern: "dist/jspdf.es.js", included: false },
20-
{ pattern: "dist/jspdf.es.js.map", included: false },
12+
"dist/polyfills.umd.js",
13+
"dist/jspdf.umd.js",
2114
"node_modules/canvg/lib/umd.js",
2215
"node_modules/html2canvas/dist/html2canvas.js",
2316
"node_modules/dompurify/dist/purify.js",

0 commit comments

Comments
 (0)