Skip to content

Commit

Permalink
Merge pull request #483 from icelam/fix-broken-test
Browse files Browse the repository at this point in the history
test: adjust optimization settings for test case which have chunks and modules imported
  • Loading branch information
icelam authored Feb 9, 2024
2 parents 2e5376c + 2654a18 commit 0995b08
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion __tests__/cases/js-with-import/expected/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta name="language" content="English"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="minimum-scale=1,initial-scale=1,width=device-width,shrink-to-fit=no"/><title>webpack test</title><script defer="defer">(()=>{var e={377:()=>{console.log("Hello world")}},r={};function o(t){var n=r[t];if(void 0!==n)return n.exports;var a=r[t]={exports:{}};return e[t](a,a.exports,o),a.exports}o.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return o.d(r,{a:r}),r},o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),(()=>{"use strict";o(377)})()})();</script></head><body><p>This is minimal code to demonstrate webpack usage</p></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta name="language" content="English"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="minimum-scale=1,initial-scale=1,width=device-width,shrink-to-fit=no"/><title>webpack test</title><script defer="defer">(()=>{var e={"./__tests__/cases/js-with-import/fixtures/app.js":()=>{console.log("Hello world")}},r={};function t(s){var o=r[s];if(void 0!==o)return o.exports;var a=r[s]={exports:{}};return e[s](a,a.exports,t),a.exports}t.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return t.d(r,{a:r}),r},t.d=(e,r)=>{for(var s in r)t.o(r,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:r[s]})},t.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),(()=>{"use strict";t("./__tests__/cases/js-with-import/fixtures/app.js")})()})();</script></head><body><p>This is minimal code to demonstrate webpack usage</p></body></html>
4 changes: 4 additions & 0 deletions __tests__/cases/js-with-import/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ const config: Configuration = {
path: path.join(__dirname, './dist'),
filename: '[name].js'
},
optimization: {
chunkIds: 'named',
moduleIds: 'named'
},
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(__dirname, './fixtures/index.html')
Expand Down
2 changes: 1 addition & 1 deletion __tests__/cases/web-worker/expected/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta name="language" content="English"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="minimum-scale=1,initial-scale=1,width=device-width,shrink-to-fit=no"/><title>webpack test</title><script defer="defer">(()=>{var e={m:{},u:e=>"test.worker.js",o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),p:"./"};e.b=document.baseURI||self.location.href;const t=new Worker(new URL(e.p+e.u(912),e.b));let n;t.onmessage=function(e){n||(n=document.createElement("div"),n.setAttribute("id","result"),document.body.append(n));const t=document.createElement("pre");t.innerHTML=JSON.stringify(e.data),n.append(t)},window.addEventListener("load",(()=>{document.getElementById("button").addEventListener("click",(()=>{t.postMessage({postMessage:!0})}))}))})();</script></head><body><p>This is minimal code to demonstrate webpack usage</p><button id="button">Run Action</button></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta name="language" content="English"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="minimum-scale=1,initial-scale=1,width=device-width,shrink-to-fit=no"/><title>webpack test</title><script defer="defer">(()=>{var e={m:{},u:e=>e+".js",o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),p:"./"};e.b=document.baseURI||self.location.href;const t=new Worker(new URL(e.p+e.u("test.worker"),e.b));let n;t.onmessage=function(e){n||(n=document.createElement("div"),n.setAttribute("id","result"),document.body.append(n));const t=document.createElement("pre");t.innerHTML=JSON.stringify(e.data),n.append(t)},window.addEventListener("load",(()=>{document.getElementById("button").addEventListener("click",(()=>{t.postMessage({postMessage:!0})}))}))})();</script></head><body><p>This is minimal code to demonstrate webpack usage</p><button id="button">Run Action</button></body></html>
4 changes: 4 additions & 0 deletions __tests__/cases/web-worker/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ const config: Configuration = {
filename: '[name].js',
publicPath: './'
},
optimization: {
chunkIds: 'named',
moduleIds: 'named'
},
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(__dirname, './fixtures/index.html')
Expand Down

0 comments on commit 0995b08

Please sign in to comment.