From 6205e489815335edee5bbe9d388fc1bcc4e8f8f3 Mon Sep 17 00:00:00 2001 From: Luis Marsano Date: Sun, 14 Jun 2020 21:00:09 -0400 Subject: [PATCH] add failing test cases for extracting scripts from html entry points fails to extract scripts for html entry points raises an exception when those scripts are ES modules pertains to peerigon/extract-loader#79 --- test/extractLoader.test.js | 22 ++++++++++++++++++++++ test/modules/esm.html | 10 ++++++++++ test/modules/esm.js | 1 + test/modules/script.html | 10 ++++++++++ test/support/compile.js | 2 +- 5 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 test/modules/esm.html create mode 100644 test/modules/esm.js create mode 100644 test/modules/script.html diff --git a/test/extractLoader.test.js b/test/extractLoader.test.js index 4bad1a9..0f48d4c 100644 --- a/test/extractLoader.test.js +++ b/test/extractLoader.test.js @@ -82,6 +82,28 @@ describe("extractLoader", () => { // ); })); + it("should extract the script.html as file, emit the referenced script and rewrite the url", () => + compile({testModule: "script.html"}).then(() => { + const scriptHtml = path.resolve(__dirname, "dist/script-dist.html"); + const scriptJs = path.resolve(__dirname, "dist/simple-dist.js"); + + expect(scriptHtml).to.be.a.file(); + expect(scriptJs).to.be.a.file(); + expect(scriptHtml).to.have.content.that.match( + / + + diff --git a/test/modules/esm.js b/test/modules/esm.js new file mode 100644 index 0000000..49c6f6a --- /dev/null +++ b/test/modules/esm.js @@ -0,0 +1 @@ +export * from 'btoa' diff --git a/test/modules/script.html b/test/modules/script.html new file mode 100644 index 0000000..11f503b --- /dev/null +++ b/test/modules/script.html @@ -0,0 +1,10 @@ + + + + + Hello World + + + + + diff --git a/test/support/compile.js b/test/support/compile.js index 1322bf9..40740e2 100644 --- a/test/support/compile.js +++ b/test/support/compile.js @@ -53,7 +53,7 @@ function compile({testModule, publicPath, loaderOptions}) { { loader: "html-loader", options: { - attrs: ["img:src", "link:href"], + attrs: ["img:src", "link:href", "script:src"], interpolate: true, }, },