-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
966 additions
and
415 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
README.md | ||
__tests__/cases/**/dist | ||
__tests__/cases/**/expected | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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">(()=>{"use strict";var e={433:e=>{e.exports="onmessage = function (event) {\n const workerResult = { timestamp: Date.now(), ...event.data };\n\n workerResult.onmessage = true;\n\n postMessage(workerResult);\n};\n"}},t={};function n(s){var o=t[s];if(void 0!==o)return o.exports;var r=t[s]={exports:{}};return e[s](r,r.exports,n),r.exports}(()=>{var e=n(433);const t=new Blob([e]),s=window.URL.createObjectURL(t),o=new Worker(s);let r;o.onmessage=function(e){r||(r=document.createElement("div"),r.setAttribute("id","result"),document.body.append(r));const t=document.createElement("pre");t.innerHTML=JSON.stringify(e.data),r.append(t)},window.addEventListener("load",(()=>{document.getElementById("button").addEventListener("click",(()=>{o.postMessage({postMessage:!0})}))}))})()})();</script></head><body><p>This is minimal code to demonstrate webpack usage</p><button id="button">Run Action</button></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!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> | ||
</head> | ||
<body> | ||
<p>This is minimal code to demonstrate webpack usage</p> | ||
<button id="button">Run Action</button> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// This file will be loaded as raw text as configured via webpack and asssets-loader | ||
// eslint-disable-next-line import/extensions, import/no-unresolved | ||
import workerSource from './worker.js?raw'; | ||
|
||
const blob = new Blob([ | ||
workerSource | ||
]); | ||
|
||
// Obtain a blob URL reference to our worker 'file'. | ||
const blobURL = window.URL.createObjectURL(blob); | ||
|
||
const worker = new Worker(blobURL); | ||
|
||
let result; | ||
|
||
worker.onmessage = function (event) { | ||
if (!result) { | ||
result = document.createElement('div'); | ||
result.setAttribute('id', 'result'); | ||
|
||
document.body.append(result); | ||
} | ||
|
||
const record = document.createElement('pre'); | ||
record.innerHTML = JSON.stringify(event.data); | ||
|
||
result.append(record); | ||
}; | ||
|
||
window.addEventListener('load', () => { | ||
const button = document.getElementById('button'); | ||
|
||
button.addEventListener('click', () => { | ||
worker.postMessage({ postMessage: true }); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
onmessage = function (event) { | ||
const workerResult = { timestamp: Date.now(), ...event.data }; | ||
|
||
workerResult.onmessage = true; | ||
|
||
postMessage(workerResult); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import path from 'path'; | ||
import type { Configuration } from 'webpack'; | ||
import HtmlWebpackPlugin from 'html-webpack-plugin'; | ||
import Self from '../../../dist'; | ||
|
||
const config: Configuration = { | ||
mode: 'production', | ||
entry: path.join(__dirname, './fixtures/index.js'), | ||
output: { | ||
path: path.join(__dirname, './dist'), | ||
filename: '[name].js', | ||
publicPath: './' | ||
}, | ||
plugins: [ | ||
new HtmlWebpackPlugin({ | ||
template: path.resolve(__dirname, './fixtures/index.html') | ||
}), | ||
new Self() | ||
], | ||
module: { | ||
rules: [ | ||
{ | ||
resourceQuery: /raw/, | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore - according to assets-loader, it is a proper usage to use 'asset/source' | ||
type: 'asset/source' | ||
} | ||
] | ||
} | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// eslint-disable-next-line no-console | ||
console.log('Hello world'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!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> | ||
</head> | ||
<body> | ||
<p>This is minimal code to demonstrate webpack usage</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import './app'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import path from 'path'; | ||
import type { Configuration } from 'webpack'; | ||
import HtmlWebpackPlugin from 'html-webpack-plugin'; | ||
import Self from '../../../dist'; | ||
|
||
const config: Configuration = { | ||
mode: 'production', | ||
entry: path.join(__dirname, './fixtures/index.js'), | ||
output: { | ||
path: path.join(__dirname, './dist'), | ||
filename: '[name].js' | ||
}, | ||
plugins: [ | ||
new HtmlWebpackPlugin({ | ||
template: path.resolve(__dirname, './fixtures/index.html') | ||
}), | ||
new Self() | ||
] | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
onmessage=function(s){const e={timestamp:Date.now(),...s.data};e.onmessage=!0,postMessage(e)}; |
Oops, something went wrong.