chore: switch to jest for testing
This commit is contained in:
parent
3b540d0c48
commit
e46f668ac8
10
.run/Template Jest.run.xml
Normal file
10
.run/Template Jest.run.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="true" type="JavaScriptTestRunnerJest">
|
||||
<node-interpreter value="/usr/bin/node" />
|
||||
<node-options value="--experimental-vm-modules" />
|
||||
<jest-options value="--detectOpenHandles" />
|
||||
<envs />
|
||||
<scope-kind value="ALL" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
@ -2,7 +2,6 @@
|
||||
const babelConfig ={
|
||||
presets: [
|
||||
["@babel/preset-typescript", {
|
||||
|
||||
}],
|
||||
],
|
||||
plugins: [
|
||||
|
||||
15
package.json
15
package.json
@ -30,8 +30,8 @@
|
||||
"ci:coverage": "nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov",
|
||||
"ci:lint": "pnpm build && pnpm lint-staged",
|
||||
"ci:test": "pnpm test -- --verbose",
|
||||
"test": "NODE_OPTIONS='--import tsx' ava",
|
||||
"save-test": "NODE_OPTIONS='--import tsx' ava --update-snapshots"
|
||||
"test": "NODE_OPTIONS='--experimental-vm-modules' jest",
|
||||
"save-test": "NODE_OPTIONS='--experimental-vm-modules' jest -u"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
@ -75,7 +75,6 @@
|
||||
"@types/node": "^18.18.12",
|
||||
"@types/react": "^18.2.0",
|
||||
"@types/react-dom": "^18.2.0",
|
||||
"ava": "^5.3.1",
|
||||
"chalk": "^5.3.0",
|
||||
"del-cli": "^5.1.0",
|
||||
"handlebars": "^4.7.8",
|
||||
@ -92,9 +91,17 @@
|
||||
"puppeteer": "^21.5.2",
|
||||
"mime": "^4.0.0",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0"
|
||||
"react-dom": "^18.2.0",
|
||||
"jest": "^29.7.0",
|
||||
"@types/jest": "^29.5.12",
|
||||
"ts-jest": "^29.1.2",
|
||||
"@jest/globals": "^29.7.0"
|
||||
},
|
||||
"types": "./types/index.d.ts",
|
||||
"jest": {
|
||||
"preset":"ts-jest/presets/default-esm",
|
||||
"setupFiles": ["./test/setup.js"]
|
||||
},
|
||||
"ava": {
|
||||
"workerThreads": false,
|
||||
"files": [
|
||||
|
||||
1158
pnpm-lock.yaml
generated
1158
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -10,7 +10,7 @@ import type {
|
||||
import type {
|
||||
LoadedReference
|
||||
} from "../types/load.d.ts";
|
||||
import {DefaultTreeAdapterMap} from "parse5";
|
||||
import type {DefaultTreeAdapterMap} from "parse5";
|
||||
|
||||
// Internal type
|
||||
export type HtmlImport = LoadedReference & {
|
||||
|
||||
@ -34,8 +34,8 @@ import posix from "node:path/posix";
|
||||
import crypto from "node:crypto";
|
||||
|
||||
// utilities
|
||||
import {makeLoader, makeInlineId} from "./loader.js";
|
||||
import {HtmlImport, HtmlModule} from "./html-module.js";
|
||||
import {makeLoader, makeInlineId} from "./loader.ts";
|
||||
import {HtmlImport, HtmlModule} from "./html-module.ts";
|
||||
|
||||
|
||||
const defaults: RollupHtmlOptions = {
|
||||
@ -266,6 +266,7 @@ export default function html(opts: RollupHtmlOptions = {}): Plugin {
|
||||
}
|
||||
|
||||
// Beware leak of AST (we're starting MagicString on a parsed and modified version of the HTML file, sourcemappings in the HTML file will be off. (can't add a sourcemap for a html file anyway, unless it is outputted as JS module)
|
||||
// @ts-ignore
|
||||
let htmlJS = new MagicString(serializeHtml(htmlModule.document));
|
||||
htmlJS.replaceAll(/`/g,'\\\`').replaceAll(/\$\{/g,'\\${');
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ import type {
|
||||
} from '../types/index.d.ts';
|
||||
import {parseFragment as parseHtmlFragment, serialize as serializeHtml, DefaultTreeAdapterMap} from "parse5";
|
||||
|
||||
import {KnownMappings, defaultMapping} from "./loader-mappings.js";
|
||||
import {KnownMappings, defaultMapping} from "./loader-mappings.ts";
|
||||
|
||||
/**
|
||||
* Makes a unique but human-readable name from a path within a HTML file.
|
||||
|
||||
78
test/basic/__snapshots__/test.js.snap
Normal file
78
test/basic/__snapshots__/test.js.snap
Normal file
@ -0,0 +1,78 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`basic inline-script 1`] = `
|
||||
[
|
||||
{
|
||||
"code": undefined,
|
||||
"fileName": "script.body.script.js-e3b82208.js.map",
|
||||
"map": undefined,
|
||||
"source": "{"version":3,"file":"script.body.script.js-e3b82208.js","sources":["../batman.js","../script.html.body.script.js"],"sourcesContent":["export const b = ()=>'batman';\\nconsole.log(b());\\n","\\n import {b} from \\"./batman.js\\";\\n document.body.appendChild(\\n document.createTextNode(\`Inline script including \${b()}\`)\\n );\\n "],"names":[],"mappings":"AAAO,MAAM,CAAC,GAAG,IAAI,QAAQ,CAAC;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;ACCJ,QAAQ,CAAC,IAAI,CAAC,WAAW;AACrC,gBAAgB,QAAQ,CAAC,cAAc,CAAC,CAAC,wBAAwB,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACzE,aAAa"}",
|
||||
},
|
||||
{
|
||||
"code": undefined,
|
||||
"fileName": "script.html",
|
||||
"map": undefined,
|
||||
"source": "<html><head>
|
||||
</head>
|
||||
<body>
|
||||
<script type="module">const b = ()=>'batman';
|
||||
console.log(b());
|
||||
|
||||
document.body.appendChild(
|
||||
document.createTextNode(\`Inline script including \${b()}\`)
|
||||
);
|
||||
//# sourceMappingURL=script.body.script.js-e3b82208.js.map
|
||||
</script>
|
||||
|
||||
|
||||
</body></html>",
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`basic simple 1`] = `
|
||||
[
|
||||
{
|
||||
"code": "const b = ()=>'batman';
|
||||
console.log(b());
|
||||
|
||||
export { b };
|
||||
//# sourceMappingURL=batman-c7fa228c.js.map
|
||||
",
|
||||
"fileName": "batman-c7fa228c.js",
|
||||
"map": SourceMap {
|
||||
"file": "batman-c7fa228c.js",
|
||||
"mappings": "AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;",
|
||||
"names": [],
|
||||
"sources": [
|
||||
"../batman.js",
|
||||
],
|
||||
"sourcesContent": [
|
||||
"export const b = ()=>'batman';
|
||||
console.log(b());
|
||||
",
|
||||
],
|
||||
"version": 3,
|
||||
},
|
||||
"source": undefined,
|
||||
},
|
||||
{
|
||||
"code": undefined,
|
||||
"fileName": "batman-c7fa228c.js.map",
|
||||
"map": undefined,
|
||||
"source": "{"version":3,"file":"batman-c7fa228c.js","sources":["../batman.js"],"sourcesContent":["export const b = ()=>'batman';\\nconsole.log(b());\\n"],"names":[],"mappings":"AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;"}",
|
||||
},
|
||||
{
|
||||
"code": undefined,
|
||||
"fileName": "index.html",
|
||||
"map": undefined,
|
||||
"source": "<html><head>
|
||||
</head>
|
||||
<body>
|
||||
<script src="batman-c7fa228c.js" type="module"></script>
|
||||
|
||||
|
||||
</body></html>",
|
||||
},
|
||||
]
|
||||
`;
|
||||
@ -1,86 +0,0 @@
|
||||
# Snapshot report for `test/basic/test.js`
|
||||
|
||||
The actual snapshot is saved in `test.js.snap`.
|
||||
|
||||
Generated by [AVA](https://avajs.dev).
|
||||
|
||||
## simple
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
[
|
||||
{
|
||||
code: `const b = ()=>'batman';␊
|
||||
console.log(b());␊
|
||||
␊
|
||||
export { b };␊
|
||||
//# sourceMappingURL=batman-c7fa228c.js.map␊
|
||||
`,
|
||||
fileName: 'batman-c7fa228c.js',
|
||||
map: SourceMap {
|
||||
file: 'batman-c7fa228c.js',
|
||||
mappings: 'AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;',
|
||||
names: [],
|
||||
sources: [
|
||||
'../batman.js',
|
||||
],
|
||||
sourcesContent: [
|
||||
`export const b = ()=>'batman';␊
|
||||
console.log(b());␊
|
||||
`,
|
||||
],
|
||||
version: 3,
|
||||
},
|
||||
source: undefined,
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'batman-c7fa228c.js.map',
|
||||
map: undefined,
|
||||
source: '{"version":3,"file":"batman-c7fa228c.js","sources":["../batman.js"],"sourcesContent":["export const b = ()=>\'batman\';\\nconsole.log(b());\\n"],"names":[],"mappings":"AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;"}',
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'index.html',
|
||||
map: undefined,
|
||||
source: `<html><head>␊
|
||||
</head>␊
|
||||
<body>␊
|
||||
<script src="batman-c7fa228c.js" type="module"></script>␊
|
||||
␊
|
||||
␊
|
||||
</body></html>`,
|
||||
},
|
||||
]
|
||||
|
||||
## inline-script
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
[
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'script.body.script.js-e3b82208.js.map',
|
||||
map: undefined,
|
||||
source: '{"version":3,"file":"script.body.script.js-e3b82208.js","sources":["../batman.js","../script.html.body.script.js"],"sourcesContent":["export const b = ()=>\'batman\';\\nconsole.log(b());\\n","\\n import {b} from \\"./batman.js\\";\\n document.body.appendChild(\\n document.createTextNode(`Inline script including ${b()}`)\\n );\\n "],"names":[],"mappings":"AAAO,MAAM,CAAC,GAAG,IAAI,QAAQ,CAAC;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;ACCJ,QAAQ,CAAC,IAAI,CAAC,WAAW;AACrC,gBAAgB,QAAQ,CAAC,cAAc,CAAC,CAAC,wBAAwB,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACzE,aAAa"}',
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'script.html',
|
||||
map: undefined,
|
||||
source: `<html><head>␊
|
||||
</head>␊
|
||||
<body>␊
|
||||
<script type="module">const b = ()=>'batman';␊
|
||||
console.log(b());␊
|
||||
␊
|
||||
document.body.appendChild(␊
|
||||
document.createTextNode(\`Inline script including ${b()}\`)␊
|
||||
);␊
|
||||
//# sourceMappingURL=script.body.script.js-e3b82208.js.map␊
|
||||
</script>␊
|
||||
␊
|
||||
␊
|
||||
</body></html>`,
|
||||
},
|
||||
]
|
||||
Binary file not shown.
@ -1,6 +1,7 @@
|
||||
import {join, dirname} from "node:path";
|
||||
|
||||
import test from "ava";
|
||||
import {test, expect} from "@jest/globals";
|
||||
|
||||
import { rollup } from "rollup";
|
||||
import {debugPrintOutput, getCode} from "../util/index.ts";
|
||||
|
||||
@ -16,35 +17,37 @@ import {fileURLToPath} from "node:url";
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
process.chdir(join(__dirname, 'fixtures'));
|
||||
|
||||
|
||||
test.serial('simple', async (t) => {
|
||||
const bundle = await rollup({
|
||||
input: 'index.html',
|
||||
plugins: [
|
||||
html({
|
||||
}),
|
||||
]
|
||||
describe("basic", ()=> {
|
||||
test('simple', async () => {
|
||||
const bundle = await rollup({
|
||||
input: 'index.html',
|
||||
plugins: [
|
||||
html({}),
|
||||
]
|
||||
});
|
||||
const code = await getCode(bundle, output);
|
||||
await bundle.close();
|
||||
debugPrintOutput('simple', code);
|
||||
expect(code).toMatchSnapshot();
|
||||
});
|
||||
const code = await getCode(bundle, output);
|
||||
debugPrintOutput('simple',code);
|
||||
t.snapshot(code);
|
||||
});
|
||||
|
||||
test.serial('inline-script', async (t) => {
|
||||
const bundle = await rollup({
|
||||
input: 'script.html',
|
||||
plugins: [
|
||||
html({
|
||||
}),
|
||||
]
|
||||
test('inline-script', async () => {
|
||||
const bundle = await rollup({
|
||||
input: 'script.html',
|
||||
plugins: [
|
||||
html({}),
|
||||
]
|
||||
});
|
||||
const code = await getCode(bundle, output);
|
||||
await bundle.close();
|
||||
debugPrintOutput('inline-script', code);
|
||||
expect(code).toMatchSnapshot();
|
||||
});
|
||||
const code = await getCode(bundle, output);
|
||||
debugPrintOutput('inline-script',code);
|
||||
t.snapshot(code);
|
||||
});
|
||||
|
||||
// TODO various parameters
|
||||
// - format: cjs, iifi, ...
|
||||
// - sourcemap: inline, false, (and the various exotic sourcemap options)
|
||||
// Watch mode tests would be its own dir
|
||||
// ...
|
||||
|
||||
});
|
||||
|
||||
190
test/evaluated-web-bundle/__snapshots__/test.js.snap
Normal file
190
test/evaluated-web-bundle/__snapshots__/test.js.snap
Normal file
@ -0,0 +1,190 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`evaluated-web-bundle 1`] = `
|
||||
{
|
||||
"code": [
|
||||
{
|
||||
"code": "async function app({root}){
|
||||
|
||||
const states = ['started', 'tick', 'ended'];
|
||||
|
||||
for(let state of states){
|
||||
const text = \`App \${state}\`;
|
||||
console.log(\`Test my sourcemap: \${text}\`);
|
||||
root.innerHTML = \`<div style="align-self: center"><b>\${text}</b></div>\`;
|
||||
await new Promise((resolve,reject)=>
|
||||
setTimeout(()=>resolve(), 10)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export { app };
|
||||
//# sourceMappingURL=app.js.map
|
||||
",
|
||||
"fileName": "app.js",
|
||||
"map": SourceMap {
|
||||
"file": "app.js",
|
||||
"mappings": "AAAO,eAAe,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;AACjC;AACA,IAAI,MAAM,MAAM,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAChD;AACA,IAAI,IAAI,IAAI,KAAK,IAAI,MAAM,CAAC;AAC5B,QAAQ,MAAM,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;AACpC,QAAQ,OAAO,CAAC,GAAG,CAAC,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AAClD,QAAQ,IAAI,CAAC,SAAS,GAAG,CAAC,mCAAmC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;AAChF,QAAQ,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM;AACzC,YAAY,UAAU,CAAC,IAAI,OAAO,EAAE,EAAE,EAAE,CAAC;AACzC,SAAS,CAAC;AACV,KAAK;AACL;;;;",
|
||||
"names": [],
|
||||
"sources": [
|
||||
"../app.mjs",
|
||||
],
|
||||
"sourcesContent": [
|
||||
"export async function app({root}){
|
||||
|
||||
const states = ['started', 'tick', 'ended'];
|
||||
|
||||
for(let state of states){
|
||||
const text = \`App \${state}\`;
|
||||
console.log(\`Test my sourcemap: \${text}\`);
|
||||
root.innerHTML = \`<div style="align-self: center"><b>\${text}</b></div>\`;
|
||||
await new Promise((resolve,reject)=>
|
||||
setTimeout(()=>resolve(), 10)
|
||||
);
|
||||
}
|
||||
}
|
||||
",
|
||||
],
|
||||
"version": 3,
|
||||
},
|
||||
"source": undefined,
|
||||
},
|
||||
{
|
||||
"code": undefined,
|
||||
"fileName": "app.js.map",
|
||||
"map": undefined,
|
||||
"source": "{"version":3,"file":"app.js","sources":["../app.mjs"],"sourcesContent":["export async function app({root}){\\n\\n const states = ['started', 'tick', 'ended'];\\n\\n for(let state of states){\\n const text = \`App \${state}\`;\\n console.log(\`Test my sourcemap: \${text}\`);\\n root.innerHTML = \`<div style=\\"align-self: center\\"><b>\${text}</b></div>\`;\\n await new Promise((resolve,reject)=>\\n setTimeout(()=>resolve(), 10)\\n );\\n }\\n}\\n"],"names":[],"mappings":"AAAO,eAAe,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;AACjC;AACA,IAAI,MAAM,MAAM,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAChD;AACA,IAAI,IAAI,IAAI,KAAK,IAAI,MAAM,CAAC;AAC5B,QAAQ,MAAM,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;AACpC,QAAQ,OAAO,CAAC,GAAG,CAAC,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AAClD,QAAQ,IAAI,CAAC,SAAS,GAAG,CAAC,mCAAmC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;AAChF,QAAQ,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM;AACzC,YAAY,UAAU,CAAC,IAAI,OAAO,EAAE,EAAE,EAAE,CAAC;AACzC,SAAS,CAAC;AACV,KAAK;AACL;;;;"}",
|
||||
},
|
||||
{
|
||||
"code": undefined,
|
||||
"fileName": "index.html",
|
||||
"map": undefined,
|
||||
"source": "<!DOCTYPE html><html lang="en"><head>
|
||||
<meta charset="UTF-8">
|
||||
<title>
|
||||
Test bundle!
|
||||
</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<link rel="icon" href="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20512%20512%22%3E%20%20%20%20%3Ctitle%3EHTML5%20Logo%3C%2Ftitle%3E%20%20%20%20%3Cpath%20d%3D%22M108.4%200h23v22.8h21.2V0h23v69h-23V46h-21v23h-23.2M206%2023h-20.3V0h63.7v23H229v46h-23M259.5%200h24.1l14.8%2024.3L313.2%200h24.1v69h-23V34.8l-16.1%2024.8l-16.1-24.8v34.2h-22.6M348.7%200h23v46.2h32.6V69h-55.6%22%2F%3E%20%20%20%20%3Cpath%20fill%3D%22%23e44d26%22%20d%3D%22M107.6%20471l-33-370.4h362.8l-33%20370.2L255.7%20512%22%2F%3E%20%20%20%20%3Cpath%20fill%3D%22%23f16529%22%20d%3D%22M256%20480.5V131H404.3L376%20447%22%2F%3E%20%20%20%20%3Cpath%20fill%3D%22%23ebebeb%22%20d%3D%22M142%20176.3h114v45.4h-64.2l4.2%2046.5h60v45.3H154.4M156.4%20336.3H202l3.2%2036.3%2050.8%2013.6v47.4l-93.2-26%22%2F%3E%20%20%20%20%3Cpath%20fill%3D%22%23fff%22%20d%3D%22M369.6%20176.3H255.8v45.4h109.6M361.3%20268.2H255.8v45.4h56l-5.3%2059-50.7%2013.6v47.2l93-25.8%22%2F%3E%3C%2Fsvg%3E">
|
||||
|
||||
<title>I'm cool!</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root">Here the app should load!</div>
|
||||
<script src="index.js" type="module"></script>
|
||||
|
||||
|
||||
</body></html>",
|
||||
},
|
||||
{
|
||||
"code": "// Dynamically loads libraries and bootstraps the application
|
||||
(async ()=>{
|
||||
// Add a loader here if any
|
||||
const root = document.getElementById('root');
|
||||
if(root) root.innerHTML= \`<div style="align-self: center">My app has loaded!!</div>\`;
|
||||
|
||||
try {
|
||||
// Load app
|
||||
const [
|
||||
appModule,
|
||||
] = await Promise.all([
|
||||
import('./app.js'),
|
||||
]);
|
||||
|
||||
console.log("Bootstrapped, ready to go!");
|
||||
|
||||
// Wait for DOM to be ready
|
||||
if(document.readyState === 'loading') {
|
||||
await new Promise((resolve)=>document.addEventListener('DOMContentLoaded', resolve));
|
||||
}
|
||||
|
||||
// Start the app!
|
||||
await appModule.app({root});
|
||||
}catch(err){
|
||||
console.error(err);
|
||||
}
|
||||
})();
|
||||
//# sourceMappingURL=index.js.map
|
||||
",
|
||||
"fileName": "index.js",
|
||||
"map": SourceMap {
|
||||
"file": "index.js",
|
||||
"mappings": "AAAA;AACA,CAAC,UAAU;AACX;AACA,IAAI,MAAM,IAAI,GAAG,QAAQ,CAAC,cAAc,CAAC,MAAM,EAAC;AAChD,IAAI,GAAG,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,yDAAyD,CAAC,CAAC;AACzF;AACA,IAAI,IAAI;AACR;AACA,QAAQ,MAAM;AACd,YAAY,SAAS;AACrB,SAAS,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;AAC9B,YAAY,OAAO,UAAW,CAAC;AAC/B,SAAS,CAAC,CAAC;AACX;AACA,QAAQ,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;AAClD;AACA;AACA,QAAQ,GAAG,QAAQ,CAAC,UAAU,KAAK,SAAS,EAAE;AAC9C,YAAY,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,GAAG,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC,CAAC;AACjG,SAAS;AACT;AACA;AACA,QAAQ,MAAM,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACpC,KAAK,MAAM,GAAG,CAAC;AACf,QAAQ,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC3B,KAAK;AACL,CAAC",
|
||||
"names": [],
|
||||
"sources": [
|
||||
"../index.mjs",
|
||||
],
|
||||
"sourcesContent": [
|
||||
"// Dynamically loads libraries and bootstraps the application
|
||||
(async ()=>{
|
||||
// Add a loader here if any
|
||||
const root = document.getElementById('root')
|
||||
if(root) root.innerHTML= \`<div style="align-self: center">My app has loaded!!</div>\`;
|
||||
|
||||
try {
|
||||
// Load app
|
||||
const [
|
||||
appModule,
|
||||
] = await Promise.all([
|
||||
import("./app.mjs"),
|
||||
]);
|
||||
|
||||
console.log("Bootstrapped, ready to go!");
|
||||
|
||||
// Wait for DOM to be ready
|
||||
if(document.readyState === 'loading') {
|
||||
await new Promise((resolve)=>document.addEventListener('DOMContentLoaded', resolve));
|
||||
}
|
||||
|
||||
// Start the app!
|
||||
await appModule.app({root});
|
||||
}catch(err){
|
||||
console.error(err);
|
||||
}
|
||||
})()
|
||||
",
|
||||
],
|
||||
"version": 3,
|
||||
},
|
||||
"source": undefined,
|
||||
},
|
||||
{
|
||||
"code": undefined,
|
||||
"fileName": "index.js.map",
|
||||
"map": undefined,
|
||||
"source": "{"version":3,"file":"index.js","sources":["../index.mjs"],"sourcesContent":["// Dynamically loads libraries and bootstraps the application\\n(async ()=>{\\n // Add a loader here if any\\n const root = document.getElementById('root')\\n if(root) root.innerHTML= \`<div style=\\"align-self: center\\">My app has loaded!!</div>\`;\\n\\n try {\\n // Load app\\n const [\\n appModule,\\n ] = await Promise.all([\\n import(\\"./app.mjs\\"),\\n ]);\\n\\n console.log(\\"Bootstrapped, ready to go!\\");\\n\\n // Wait for DOM to be ready\\n if(document.readyState === 'loading') {\\n await new Promise((resolve)=>document.addEventListener('DOMContentLoaded', resolve));\\n }\\n\\n // Start the app!\\n await appModule.app({root});\\n }catch(err){\\n console.error(err);\\n }\\n})()\\n"],"names":[],"mappings":"AAAA;AACA,CAAC,UAAU;AACX;AACA,IAAI,MAAM,IAAI,GAAG,QAAQ,CAAC,cAAc,CAAC,MAAM,EAAC;AAChD,IAAI,GAAG,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,yDAAyD,CAAC,CAAC;AACzF;AACA,IAAI,IAAI;AACR;AACA,QAAQ,MAAM;AACd,YAAY,SAAS;AACrB,SAAS,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;AAC9B,YAAY,OAAO,UAAW,CAAC;AAC/B,SAAS,CAAC,CAAC;AACX;AACA,QAAQ,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;AAClD;AACA;AACA,QAAQ,GAAG,QAAQ,CAAC,UAAU,KAAK,SAAS,EAAE;AAC9C,YAAY,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,GAAG,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC,CAAC;AACjG,SAAS;AACT;AACA;AACA,QAAQ,MAAM,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACpC,KAAK,MAAM,GAAG,CAAC;AACf,QAAQ,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC3B,KAAK;AACL,CAAC"}",
|
||||
},
|
||||
],
|
||||
"console": [
|
||||
"[log] Bootstrapped, ready to go!",
|
||||
"[log] Test my sourcemap: App started",
|
||||
"[log] Test my sourcemap: App tick",
|
||||
"[log] Test my sourcemap: App ended",
|
||||
],
|
||||
"errors": [],
|
||||
"html": "<html lang="en"><head>
|
||||
<meta charset="UTF-8">
|
||||
<title>
|
||||
Test bundle!
|
||||
</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<link rel="icon" href="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20512%20512%22%3E%20%20%20%20%3Ctitle%3EHTML5%20Logo%3C%2Ftitle%3E%20%20%20%20%3Cpath%20d%3D%22M108.4%200h23v22.8h21.2V0h23v69h-23V46h-21v23h-23.2M206%2023h-20.3V0h63.7v23H229v46h-23M259.5%200h24.1l14.8%2024.3L313.2%200h24.1v69h-23V34.8l-16.1%2024.8l-16.1-24.8v34.2h-22.6M348.7%200h23v46.2h32.6V69h-55.6%22%2F%3E%20%20%20%20%3Cpath%20fill%3D%22%23e44d26%22%20d%3D%22M107.6%20471l-33-370.4h362.8l-33%20370.2L255.7%20512%22%2F%3E%20%20%20%20%3Cpath%20fill%3D%22%23f16529%22%20d%3D%22M256%20480.5V131H404.3L376%20447%22%2F%3E%20%20%20%20%3Cpath%20fill%3D%22%23ebebeb%22%20d%3D%22M142%20176.3h114v45.4h-64.2l4.2%2046.5h60v45.3H154.4M156.4%20336.3H202l3.2%2036.3%2050.8%2013.6v47.4l-93.2-26%22%2F%3E%20%20%20%20%3Cpath%20fill%3D%22%23fff%22%20d%3D%22M369.6%20176.3H255.8v45.4h109.6M361.3%20268.2H255.8v45.4h56l-5.3%2059-50.7%2013.6v47.2l93-25.8%22%2F%3E%3C%2Fsvg%3E">
|
||||
|
||||
<title>I'm cool!</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"><div style="align-self: center"><b>App ended</b></div></div>
|
||||
<script src="index.js" type="module"></script>
|
||||
|
||||
|
||||
</body></html>",
|
||||
"requestsFailed": [],
|
||||
"responses": [
|
||||
"200 http://localhost/index.html",
|
||||
"200 http://localhost/index.js",
|
||||
"200 http://localhost/app.js",
|
||||
],
|
||||
}
|
||||
`;
|
||||
@ -1,42 +0,0 @@
|
||||
# Snapshot report for `test/evaluated-web-bundle/test.js`
|
||||
|
||||
The actual snapshot is saved in `test.js.snap`.
|
||||
|
||||
Generated by [AVA](https://avajs.dev).
|
||||
|
||||
## web-bundle
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
{
|
||||
console: [
|
||||
'[log] Bootstrapped, ready to go!',
|
||||
'[log] Test my sourcemap: App started',
|
||||
'[log] Test my sourcemap: App tick',
|
||||
'[log] Test my sourcemap: App ended',
|
||||
],
|
||||
errors: [],
|
||||
html: `<html lang="en"><head>␊
|
||||
<meta charset="UTF-8">␊
|
||||
<title>␊
|
||||
Test bundle!␊
|
||||
</title>␊
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">␊
|
||||
␊
|
||||
<link rel="icon" href="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20512%20512%22%3E%20%20%20%20%3Ctitle%3EHTML5%20Logo%3C%2Ftitle%3E%20%20%20%20%3Cpath%20d%3D%22M108.4%200h23v22.8h21.2V0h23v69h-23V46h-21v23h-23.2M206%2023h-20.3V0h63.7v23H229v46h-23M259.5%200h24.1l14.8%2024.3L313.2%200h24.1v69h-23V34.8l-16.1%2024.8l-16.1-24.8v34.2h-22.6M348.7%200h23v46.2h32.6V69h-55.6%22%2F%3E%20%20%20%20%3Cpath%20fill%3D%22%23e44d26%22%20d%3D%22M107.6%20471l-33-370.4h362.8l-33%20370.2L255.7%20512%22%2F%3E%20%20%20%20%3Cpath%20fill%3D%22%23f16529%22%20d%3D%22M256%20480.5V131H404.3L376%20447%22%2F%3E%20%20%20%20%3Cpath%20fill%3D%22%23ebebeb%22%20d%3D%22M142%20176.3h114v45.4h-64.2l4.2%2046.5h60v45.3H154.4M156.4%20336.3H202l3.2%2036.3%2050.8%2013.6v47.4l-93.2-26%22%2F%3E%20%20%20%20%3Cpath%20fill%3D%22%23fff%22%20d%3D%22M369.6%20176.3H255.8v45.4h109.6M361.3%20268.2H255.8v45.4h56l-5.3%2059-50.7%2013.6v47.2l93-25.8%22%2F%3E%3C%2Fsvg%3E">␊
|
||||
␊
|
||||
<title>I'm cool!</title>␊
|
||||
</head>␊
|
||||
<body>␊
|
||||
<div id="root"><div style="align-self: center"><b>App ended</b></div></div>␊
|
||||
<script src="index.js" type="module"></script>␊
|
||||
␊
|
||||
␊
|
||||
</body></html>`,
|
||||
requestsFailed: [],
|
||||
responses: [
|
||||
'200 http://localhost/index.html',
|
||||
'200 http://localhost/index.js',
|
||||
'200 http://localhost/app.js',
|
||||
],
|
||||
}
|
||||
Binary file not shown.
@ -1,7 +1,6 @@
|
||||
import {join, dirname} from "node:path";
|
||||
import {test, expect} from "@jest/globals";
|
||||
|
||||
import test from "ava";
|
||||
import { rollup } from "rollup";
|
||||
import urlPlugin from "@rollup/plugin-url";
|
||||
|
||||
import html from "../../src/index.ts";
|
||||
@ -20,7 +19,7 @@ const defaultAssetInclude = [
|
||||
'**/*.(webm|mp4)',// video
|
||||
];
|
||||
|
||||
test.serial('web-bundle', async (t) => {
|
||||
test('evaluated-web-bundle', async ()=>{
|
||||
const out = await runBrowserTest({
|
||||
input: 'index.hbs',
|
||||
treeshake: 'smallest',
|
||||
@ -38,7 +37,6 @@ test.serial('web-bundle', async (t) => {
|
||||
],
|
||||
}, {
|
||||
path: 'index.html',
|
||||
log: t.log,
|
||||
},{
|
||||
dir: 'output', // Output all files
|
||||
format: 'es', // iifi and cjs should be added to tests
|
||||
@ -47,7 +45,5 @@ test.serial('web-bundle', async (t) => {
|
||||
entryFileNames: '[name].[extname]',
|
||||
assetFileNames: '[name].[extname]',
|
||||
});
|
||||
t.snapshot(out);
|
||||
// await bundle.generate(output);
|
||||
expect(out).toMatchSnapshot();
|
||||
});
|
||||
|
||||
|
||||
69
test/js-import/__snapshots__/test.js.snap
Normal file
69
test/js-import/__snapshots__/test.js.snap
Normal file
@ -0,0 +1,69 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`js-import 1`] = `
|
||||
[
|
||||
{
|
||||
"code": "var asset0 = "data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%2032%2032%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%20%20%3Cpath%20style%3D%22fill%3Anone%3Bstroke%3A%2300ff0d%3Bstroke-width%3A5%3Bstroke-linecap%3Asquare%3Bstroke-linejoin%3Amiter%3Bstroke-dasharray%3Anone%3Bstroke-opacity%3A1%22%20d%3D%22M4.1%2014.72%2016%2026.31%2028.38%205.09%22%2F%3E%3C%2Fsvg%3E";
|
||||
|
||||
const html = \`<html><head>
|
||||
<link rel="icon" href="\${asset0}">
|
||||
<!-- TODO: support for css imports are yet to be added (as simple assets or through a preprocessor-->
|
||||
<!-- <link rel="stylesheet" href="./joker.css">-->
|
||||
</head>
|
||||
<body>
|
||||
<!-- TODO: this shouldn't have been commented out, but our plugin fails if it is included (which shoudn't happen!!) -->
|
||||
<!--<script src="./batman.js" type="module"></script>-->
|
||||
|
||||
|
||||
</body></html>\`;
|
||||
|
||||
function render(){
|
||||
return html;
|
||||
}
|
||||
|
||||
export { render };
|
||||
//# sourceMappingURL=index-3d1ca61b.js.map
|
||||
",
|
||||
"fileName": "index-3d1ca61b.js",
|
||||
"map": SourceMap {
|
||||
"file": "index-3d1ca61b.js",
|
||||
"mappings": "AAAA,aAAe;;ACAf,MAAA,IAAA,GAAA,CAAA;AACA,+BAA+B,EAAwD,MAAA,CAAA;AACvF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAa,CAAA;;ACRN,SAAS,MAAM,EAAE;AACxB,IAAI,OAAO,IAAI,CAAC;AAChB;;;;",
|
||||
"names": [],
|
||||
"sources": [
|
||||
"../icon.svg",
|
||||
"../index.html",
|
||||
"../index.js",
|
||||
],
|
||||
"sourcesContent": [
|
||||
"export default "data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%2032%2032%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%20%20%3Cpath%20style%3D%22fill%3Anone%3Bstroke%3A%2300ff0d%3Bstroke-width%3A5%3Bstroke-linecap%3Asquare%3Bstroke-linejoin%3Amiter%3Bstroke-dasharray%3Anone%3Bstroke-opacity%3A1%22%20d%3D%22M4.1%2014.72%2016%2026.31%2028.38%205.09%22%2F%3E%3C%2Fsvg%3E"",
|
||||
"<html>
|
||||
<head>
|
||||
<link rel="icon" href="./icon.svg">
|
||||
<!-- TODO: support for css imports are yet to be added (as simple assets or through a preprocessor-->
|
||||
<!-- <link rel="stylesheet" href="./joker.css">-->
|
||||
</head>
|
||||
<body>
|
||||
<!-- TODO: this shouldn't have been commented out, but our plugin fails if it is included (which shoudn't happen!!) -->
|
||||
<!--<script src="./batman.js" type="module"></script>-->
|
||||
</body>
|
||||
</html>
|
||||
",
|
||||
"import html from "./index.html"
|
||||
|
||||
export function render(){
|
||||
return html;
|
||||
}
|
||||
",
|
||||
],
|
||||
"version": 3,
|
||||
},
|
||||
"source": undefined,
|
||||
},
|
||||
{
|
||||
"code": undefined,
|
||||
"fileName": "index-3d1ca61b.js.map",
|
||||
"map": undefined,
|
||||
"source": "{"version":3,"file":"index-3d1ca61b.js","sources":["../icon.svg","../index.html","../index.js"],"sourcesContent":["export default \\"data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%2032%2032%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%20%20%3Cpath%20style%3D%22fill%3Anone%3Bstroke%3A%2300ff0d%3Bstroke-width%3A5%3Bstroke-linecap%3Asquare%3Bstroke-linejoin%3Amiter%3Bstroke-dasharray%3Anone%3Bstroke-opacity%3A1%22%20d%3D%22M4.1%2014.72%2016%2026.31%2028.38%205.09%22%2F%3E%3C%2Fsvg%3E\\"","<html>\\n <head>\\n <link rel=\\"icon\\" href=\\"./icon.svg\\">\\n <!-- TODO: support for css imports are yet to be added (as simple assets or through a preprocessor-->\\n<!-- <link rel=\\"stylesheet\\" href=\\"./joker.css\\">-->\\n </head>\\n <body>\\n <!-- TODO: this shouldn't have been commented out, but our plugin fails if it is included (which shoudn't happen!!) -->\\n <!--<script src=\\"./batman.js\\" type=\\"module\\"></script>-->\\n </body>\\n</html>\\n","import html from \\"./index.html\\"\\n\\nexport function render(){\\n return html;\\n}\\n"],"names":[],"mappings":"AAAA,aAAe;;ACAf,MAAA,IAAA,GAAA,CAAA;AACA,+BAA+B,EAAwD,MAAA,CAAA;AACvF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAa,CAAA;;ACRN,SAAS,MAAM,EAAE;AACxB,IAAI,OAAO,IAAI,CAAC;AAChB;;;;"}",
|
||||
},
|
||||
]
|
||||
`;
|
||||
@ -1,75 +0,0 @@
|
||||
# Snapshot report for `test/js-import/test.js`
|
||||
|
||||
The actual snapshot is saved in `test.js.snap`.
|
||||
|
||||
Generated by [AVA](https://avajs.dev).
|
||||
|
||||
## js-import
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
[
|
||||
{
|
||||
code: `var asset0 = "data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%2032%2032%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%20%20%3Cpath%20style%3D%22fill%3Anone%3Bstroke%3A%2300ff0d%3Bstroke-width%3A5%3Bstroke-linecap%3Asquare%3Bstroke-linejoin%3Amiter%3Bstroke-dasharray%3Anone%3Bstroke-opacity%3A1%22%20d%3D%22M4.1%2014.72%2016%2026.31%2028.38%205.09%22%2F%3E%3C%2Fsvg%3E";␊
|
||||
␊
|
||||
const html = \`<html><head>␊
|
||||
<link rel="icon" href="${asset0}">␊
|
||||
<!-- TODO: support for css imports are yet to be added (as simple assets or through a preprocessor-->␊
|
||||
<!-- <link rel="stylesheet" href="./joker.css">-->␊
|
||||
</head>␊
|
||||
<body>␊
|
||||
<!-- TODO: this shouldn't have been commented out, but our plugin fails if it is included (which shoudn't happen!!) -->␊
|
||||
<!--<script src="./batman.js" type="module"></script>-->␊
|
||||
␊
|
||||
␊
|
||||
</body></html>\`;␊
|
||||
␊
|
||||
function render(){␊
|
||||
return html;␊
|
||||
}␊
|
||||
␊
|
||||
export { render };␊
|
||||
//# sourceMappingURL=index-3d1ca61b.js.map␊
|
||||
`,
|
||||
fileName: 'index-3d1ca61b.js',
|
||||
map: SourceMap {
|
||||
file: 'index-3d1ca61b.js',
|
||||
mappings: 'AAAA,aAAe;;ACAf,MAAA,IAAA,GAAA,CAAA;AACA,+BAA+B,EAAwD,MAAA,CAAA;AACvF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAa,CAAA;;ACRN,SAAS,MAAM,EAAE;AACxB,IAAI,OAAO,IAAI,CAAC;AAChB;;;;',
|
||||
names: [],
|
||||
sources: [
|
||||
'../icon.svg',
|
||||
'../index.html',
|
||||
'../index.js',
|
||||
],
|
||||
sourcesContent: [
|
||||
'export default "data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%2032%2032%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%20%20%3Cpath%20style%3D%22fill%3Anone%3Bstroke%3A%2300ff0d%3Bstroke-width%3A5%3Bstroke-linecap%3Asquare%3Bstroke-linejoin%3Amiter%3Bstroke-dasharray%3Anone%3Bstroke-opacity%3A1%22%20d%3D%22M4.1%2014.72%2016%2026.31%2028.38%205.09%22%2F%3E%3C%2Fsvg%3E"',
|
||||
`<html>␊
|
||||
<head>␊
|
||||
<link rel="icon" href="./icon.svg">␊
|
||||
<!-- TODO: support for css imports are yet to be added (as simple assets or through a preprocessor-->␊
|
||||
<!-- <link rel="stylesheet" href="./joker.css">-->␊
|
||||
</head>␊
|
||||
<body>␊
|
||||
<!-- TODO: this shouldn't have been commented out, but our plugin fails if it is included (which shoudn't happen!!) -->␊
|
||||
<!--<script src="./batman.js" type="module"></script>-->␊
|
||||
</body>␊
|
||||
</html>␊
|
||||
`,
|
||||
`import html from "./index.html"␊
|
||||
␊
|
||||
export function render(){␊
|
||||
return html;␊
|
||||
}␊
|
||||
`,
|
||||
],
|
||||
version: 3,
|
||||
},
|
||||
source: undefined,
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'index-3d1ca61b.js.map',
|
||||
map: undefined,
|
||||
source: '{"version":3,"file":"index-3d1ca61b.js","sources":["../icon.svg","../index.html","../index.js"],"sourcesContent":["export default \\"data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%2032%2032%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%20%20%3Cpath%20style%3D%22fill%3Anone%3Bstroke%3A%2300ff0d%3Bstroke-width%3A5%3Bstroke-linecap%3Asquare%3Bstroke-linejoin%3Amiter%3Bstroke-dasharray%3Anone%3Bstroke-opacity%3A1%22%20d%3D%22M4.1%2014.72%2016%2026.31%2028.38%205.09%22%2F%3E%3C%2Fsvg%3E\\"","<html>\\n <head>\\n <link rel=\\"icon\\" href=\\"./icon.svg\\">\\n <!-- TODO: support for css imports are yet to be added (as simple assets or through a preprocessor-->\\n<!-- <link rel=\\"stylesheet\\" href=\\"./joker.css\\">-->\\n </head>\\n <body>\\n <!-- TODO: this shouldn\'t have been commented out, but our plugin fails if it is included (which shoudn\'t happen!!) -->\\n <!--<script src=\\"./batman.js\\" type=\\"module\\"></script>-->\\n </body>\\n</html>\\n","import html from \\"./index.html\\"\\n\\nexport function render(){\\n return html;\\n}\\n"],"names":[],"mappings":"AAAA,aAAe;;ACAf,MAAA,IAAA,GAAA,CAAA;AACA,+BAA+B,EAAwD,MAAA,CAAA;AACvF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAa,CAAA;;ACRN,SAAS,MAAM,EAAE;AACxB,IAAI,OAAO,IAAI,CAAC;AAChB;;;;"}',
|
||||
},
|
||||
]
|
||||
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
import {join, dirname} from "node:path";
|
||||
import {test, expect} from "@jest/globals";
|
||||
|
||||
import test from "ava";
|
||||
import { rollup } from "rollup";
|
||||
|
||||
import {debugPrintOutput, getCode} from "../util/index.ts";
|
||||
@ -25,7 +25,8 @@ const defaultAssetInclude = [
|
||||
'**/*.(webm|mp4)',// video
|
||||
];
|
||||
|
||||
test.serial('js-import', async (t) => {
|
||||
|
||||
test('js-import', async () => {
|
||||
const bundle = await rollup({
|
||||
input: 'index.js',
|
||||
plugins: [
|
||||
@ -40,7 +41,7 @@ test.serial('js-import', async (t) => {
|
||||
});
|
||||
const code = await getCode(bundle, output);
|
||||
debugPrintOutput('js-import',code);
|
||||
t.snapshot(code);
|
||||
expect(code).toMatchSnapshot();
|
||||
});
|
||||
|
||||
|
||||
|
||||
48264
test/jsx-web-app/__snapshots__/test.js.snap
Normal file
48264
test/jsx-web-app/__snapshots__/test.js.snap
Normal file
File diff suppressed because one or more lines are too long
@ -1,6 +1,5 @@
|
||||
import {join, dirname} from "node:path";
|
||||
|
||||
import test from "ava";
|
||||
import {test, expect, jest} from "@jest/globals";
|
||||
|
||||
// Rollup * plugins
|
||||
import { rollup } from "rollup";
|
||||
@ -27,7 +26,9 @@ const defaultAssetInclude = [
|
||||
'**/*.(webm|mp4)',// video
|
||||
];
|
||||
|
||||
test.serial('web-bundle', async (t) => {
|
||||
|
||||
jest.setTimeout(30*1000);// Bundling react + typescript is getting heavy
|
||||
test('web-bundle', async () => {
|
||||
const out = await runBrowserTest({
|
||||
input: 'index.hbs',
|
||||
treeshake: 'smallest',
|
||||
@ -67,8 +68,7 @@ test.serial('web-bundle', async (t) => {
|
||||
}),
|
||||
],
|
||||
}, {
|
||||
path: 'index.html',
|
||||
log: t.log,
|
||||
path: 'index.html'
|
||||
},{
|
||||
dir: 'output', // Output all files
|
||||
format: 'es', // iifi and cjs should be added to tests
|
||||
@ -77,7 +77,7 @@ test.serial('web-bundle', async (t) => {
|
||||
entryFileNames: '[name].[extname]',
|
||||
assetFileNames: '[name].[extname]',
|
||||
});
|
||||
t.snapshot(out);
|
||||
expect(out).toMatchSnapshot();
|
||||
|
||||
// const code = await getCode(bundle, output);
|
||||
// debugPrintOutput('jsx-web-app',code);
|
||||
|
||||
54
test/live-reload/__snapshots__/test.js.snap
Normal file
54
test/live-reload/__snapshots__/test.js.snap
Normal file
@ -0,0 +1,54 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`live-reload 1`] = `
|
||||
[
|
||||
{
|
||||
"code": "
|
||||
(function(l, r) { if (!l || l.getElementById('livereloadscript')) return; r = l.createElement('script'); r.async = 1; r.src = '//' + (self.location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1'; r.id = 'livereloadscript'; l.getElementsByTagName('head')[0].appendChild(r) })(self.document);
|
||||
const test = ()=>{
|
||||
return \`I'm "annoying" \${"in case we need to test \\\`string\\\` escaping."}. Hence this files \\'tries\\' to include all allowed forms of 'it'\`;
|
||||
};
|
||||
console.log(test());
|
||||
|
||||
export { test };
|
||||
//# sourceMappingURL=batman-1a5fc364.js.map
|
||||
",
|
||||
"fileName": "batman-1a5fc364.js",
|
||||
"map": SourceMap {
|
||||
"file": "batman-1a5fc364.js",
|
||||
"mappings": ";;AAAY,MAAC,IAAI,GAAG,IAAI;AACxB,IAAI,OAAO,CAAC,eAAe,EAAE,8CAA8C,CAAC,iEAAiE,CAAC,CAAC;AAC/I,EAAC;AACD,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;;;;",
|
||||
"names": [],
|
||||
"sources": [
|
||||
"../batman.js",
|
||||
],
|
||||
"sourcesContent": [
|
||||
"export const test = ()=>{
|
||||
return \`I'm "annoying" \${"in case we need to test \\\`string\\\` escaping."}. Hence this files \\'tries\\' to include all allowed forms of 'it'\`;
|
||||
}
|
||||
console.log(test());
|
||||
",
|
||||
],
|
||||
"version": 3,
|
||||
},
|
||||
"source": undefined,
|
||||
},
|
||||
{
|
||||
"code": undefined,
|
||||
"fileName": "batman-1a5fc364.js.map",
|
||||
"map": undefined,
|
||||
"source": "{"version":3,"file":"batman-1a5fc364.js","sources":["../batman.js"],"sourcesContent":["export const test = ()=>{\\n return \`I'm \\"annoying\\" \${\\"in case we need to test \\\\\`string\\\\\` escaping.\\"}. Hence this files \\\\'tries\\\\' to include all allowed forms of 'it'\`;\\n}\\nconsole.log(test());\\n"],"names":[],"mappings":";;AAAY,MAAC,IAAI,GAAG,IAAI;AACxB,IAAI,OAAO,CAAC,eAAe,EAAE,8CAA8C,CAAC,iEAAiE,CAAC,CAAC;AAC/I,EAAC;AACD,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;;;;"}",
|
||||
},
|
||||
{
|
||||
"code": undefined,
|
||||
"fileName": "index.html",
|
||||
"map": undefined,
|
||||
"source": "<html><head>
|
||||
</head>
|
||||
<body>
|
||||
<script src="batman-1a5fc364.js" type="module"></script>
|
||||
|
||||
|
||||
</body></html>",
|
||||
},
|
||||
]
|
||||
`;
|
||||
@ -1,60 +0,0 @@
|
||||
# Snapshot report for `test/live-reload/test.js`
|
||||
|
||||
The actual snapshot is saved in `test.js.snap`.
|
||||
|
||||
Generated by [AVA](https://avajs.dev).
|
||||
|
||||
## live-reload
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
[
|
||||
{
|
||||
code: `␊
|
||||
(function(l, r) { if (!l || l.getElementById('livereloadscript')) return; r = l.createElement('script'); r.async = 1; r.src = '//' + (self.location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1'; r.id = 'livereloadscript'; l.getElementsByTagName('head')[0].appendChild(r) })(self.document);␊
|
||||
const test = ()=>{␊
|
||||
return \`I'm "annoying" ${"in case we need to test \\\`string\\\` escaping."}. Hence this files \\'tries\\' to include all allowed forms of 'it'\`;␊
|
||||
};␊
|
||||
console.log(test());␊
|
||||
␊
|
||||
export { test };␊
|
||||
//# sourceMappingURL=batman-1a5fc364.js.map␊
|
||||
`,
|
||||
fileName: 'batman-1a5fc364.js',
|
||||
map: SourceMap {
|
||||
file: 'batman-1a5fc364.js',
|
||||
mappings: ';;AAAY,MAAC,IAAI,GAAG,IAAI;AACxB,IAAI,OAAO,CAAC,eAAe,EAAE,8CAA8C,CAAC,iEAAiE,CAAC,CAAC;AAC/I,EAAC;AACD,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;;;;',
|
||||
names: [],
|
||||
sources: [
|
||||
'../batman.js',
|
||||
],
|
||||
sourcesContent: [
|
||||
`export const test = ()=>{␊
|
||||
return \`I'm "annoying" ${"in case we need to test \\\`string\\\` escaping."}. Hence this files \\'tries\\' to include all allowed forms of 'it'\`;␊
|
||||
}␊
|
||||
console.log(test());␊
|
||||
`,
|
||||
],
|
||||
version: 3,
|
||||
},
|
||||
source: undefined,
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'batman-1a5fc364.js.map',
|
||||
map: undefined,
|
||||
source: '{"version":3,"file":"batman-1a5fc364.js","sources":["../batman.js"],"sourcesContent":["export const test = ()=>{\\n return `I\'m \\"annoying\\" ${\\"in case we need to test \\\\`string\\\\` escaping.\\"}. Hence this files \\\\\'tries\\\\\' to include all allowed forms of \'it\'`;\\n}\\nconsole.log(test());\\n"],"names":[],"mappings":";;AAAY,MAAC,IAAI,GAAG,IAAI;AACxB,IAAI,OAAO,CAAC,eAAe,EAAE,8CAA8C,CAAC,iEAAiE,CAAC,CAAC;AAC/I,EAAC;AACD,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;;;;"}',
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'index.html',
|
||||
map: undefined,
|
||||
source: `<html><head>␊
|
||||
</head>␊
|
||||
<body>␊
|
||||
<script src="batman-1a5fc364.js" type="module"></script>␊
|
||||
␊
|
||||
␊
|
||||
</body></html>`,
|
||||
},
|
||||
]
|
||||
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
import {join, dirname} from "node:path";
|
||||
import {test, expect} from "@jest/globals";
|
||||
|
||||
import test from "ava";
|
||||
import {rollup} from "rollup";
|
||||
import liveReload from "rollup-plugin-livereload";
|
||||
import {debugPrintOutput, getCode} from "../util/index.ts";
|
||||
@ -18,7 +18,7 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
process.chdir(join(__dirname, 'fixtures'));
|
||||
|
||||
|
||||
test.serial('live-reload', async (t) => {
|
||||
test('live-reload', async () => {
|
||||
const bundle = await rollup({
|
||||
input: 'index.html',
|
||||
plugins: [
|
||||
@ -32,7 +32,7 @@ test.serial('live-reload', async (t) => {
|
||||
const code = await getCode(bundle, output);
|
||||
await bundle.close();// Make sure live-reload closes itself
|
||||
debugPrintOutput('live-reload',code);
|
||||
t.snapshot(code);
|
||||
expect(code).toMatchSnapshot();
|
||||
});
|
||||
|
||||
// TODO various parameters
|
||||
|
||||
125
test/multi-entry/__snapshots__/test.js.snap
Normal file
125
test/multi-entry/__snapshots__/test.js.snap
Normal file
@ -0,0 +1,125 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`multi-entry 1`] = `
|
||||
[
|
||||
{
|
||||
"code": "const b = ()=>'batman';
|
||||
console.log(b());
|
||||
|
||||
export { b };
|
||||
//# sourceMappingURL=batman-c7fa228c.js.map
|
||||
",
|
||||
"fileName": "admin/batman-c7fa228c.js",
|
||||
"map": SourceMap {
|
||||
"file": "batman-c7fa228c.js",
|
||||
"mappings": "AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;",
|
||||
"names": [],
|
||||
"sources": [
|
||||
"../../admin/batman.js",
|
||||
],
|
||||
"sourcesContent": [
|
||||
"export const b = ()=>'batman';
|
||||
console.log(b());
|
||||
",
|
||||
],
|
||||
"version": 3,
|
||||
},
|
||||
"source": undefined,
|
||||
},
|
||||
{
|
||||
"code": undefined,
|
||||
"fileName": "admin/batman-c7fa228c.js.map",
|
||||
"map": undefined,
|
||||
"source": "{"version":3,"file":"batman-c7fa228c.js","sources":["../../admin/batman.js"],"sourcesContent":["export const b = ()=>'batman';\\nconsole.log(b());\\n"],"names":[],"mappings":"AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;"}",
|
||||
},
|
||||
{
|
||||
"code": undefined,
|
||||
"fileName": "admin/index.body.script0.js-15dfaff3.js.map",
|
||||
"map": undefined,
|
||||
"source": "{"version":3,"file":"index.body.script0.js-15dfaff3.js","sources":["../../app/admin-deps.js","../../admin/index.html.body.script0.js"],"sourcesContent":["export function adminDeps(){\\n return \\"robin!\\";\\n}\\n","\\n import {bootstrap} from \\"../app/app.js\\"\\n import {adminDeps} from \\"../app/admin-deps.js\\";\\n bootstrap(document.getElementById('root'), adminDeps());\\n "],"names":[],"mappings":";;AAAO,SAAS,SAAS,EAAE;AAC3B,IAAI,OAAO,QAAQ,CAAC;AACpB;;ACCY,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC"}",
|
||||
},
|
||||
{
|
||||
"code": undefined,
|
||||
"fileName": "admin/index.html",
|
||||
"map": undefined,
|
||||
"source": "<html><head>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module">import { b as bootstrap } from '../app-01141b67.js';
|
||||
|
||||
function adminDeps(){
|
||||
return "robin!";
|
||||
}
|
||||
|
||||
bootstrap(document.getElementById('root'), adminDeps());
|
||||
//# sourceMappingURL=index.body.script0.js-15dfaff3.js.map
|
||||
</script>
|
||||
<script src="batman-c7fa228c.js" type="module"></script>
|
||||
|
||||
|
||||
</body></html>",
|
||||
},
|
||||
{
|
||||
"code": "const bootstrap = (el,deps = [])=>{
|
||||
el.innerHtml = \`
|
||||
<div>I'm "annoying" \${"in case we need to test \\\`string\\\` escaping."}. Hence this file \\'tries\\' to include all allowed forms of 'it'</div>
|
||||
<div>Deps: \${deps}</div>
|
||||
\`;
|
||||
};
|
||||
|
||||
export { bootstrap as b };
|
||||
//# sourceMappingURL=app-01141b67.js.map
|
||||
",
|
||||
"fileName": "app-01141b67.js",
|
||||
"map": SourceMap {
|
||||
"file": "app-01141b67.js",
|
||||
"mappings": "AAAY,MAAC,SAAS,GAAG,CAAC,EAAE,CAAC,IAAI,GAAG,EAAE,GAAG;AACzC,IAAI,EAAE,CAAC,SAAS,GAAG,CAAC;AACpB,4BAA4B,EAAE,8CAA8C,CAAC;AAC7E,mBAAmB,EAAE,IAAI,CAAC;AAC1B,IAAI,CAAC,CAAC;AACN;;;;",
|
||||
"names": [],
|
||||
"sources": [
|
||||
"../app/app.js",
|
||||
],
|
||||
"sourcesContent": [
|
||||
"export const bootstrap = (el,deps = [])=>{
|
||||
el.innerHtml = \`
|
||||
<div>I'm "annoying" \${"in case we need to test \\\`string\\\` escaping."}. Hence this file \\'tries\\' to include all allowed forms of 'it'</div>
|
||||
<div>Deps: \${deps}</div>
|
||||
\`;
|
||||
}
|
||||
",
|
||||
],
|
||||
"version": 3,
|
||||
},
|
||||
"source": undefined,
|
||||
},
|
||||
{
|
||||
"code": undefined,
|
||||
"fileName": "app-01141b67.js.map",
|
||||
"map": undefined,
|
||||
"source": "{"version":3,"file":"app-01141b67.js","sources":["../app/app.js"],"sourcesContent":["export const bootstrap = (el,deps = [])=>{\\n el.innerHtml = \`\\n <div>I'm \\"annoying\\" \${\\"in case we need to test \\\\\`string\\\\\` escaping.\\"}. Hence this file \\\\'tries\\\\' to include all allowed forms of 'it'</div>\\n <div>Deps: \${deps}</div>\\n \`;\\n}\\n"],"names":[],"mappings":"AAAY,MAAC,SAAS,GAAG,CAAC,EAAE,CAAC,IAAI,GAAG,EAAE,GAAG;AACzC,IAAI,EAAE,CAAC,SAAS,GAAG,CAAC;AACpB,4BAA4B,EAAE,8CAA8C,CAAC;AAC7E,mBAAmB,EAAE,IAAI,CAAC;AAC1B,IAAI,CAAC,CAAC;AACN;;;;"}",
|
||||
},
|
||||
{
|
||||
"code": undefined,
|
||||
"fileName": "index.body.script.js-45303f0f.js.map",
|
||||
"map": undefined,
|
||||
"source": "{"version":3,"file":"index.body.script.js-45303f0f.js","sources":["../index.html.body.script.js"],"sourcesContent":["\\n import {bootstrap} from \\"./app/app.js\\"\\n bootstrap(document.getElementById('root'), \\"<none>\\");\\n "],"names":[],"mappings":";;AAEY,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC"}",
|
||||
},
|
||||
{
|
||||
"code": undefined,
|
||||
"fileName": "index.html",
|
||||
"map": undefined,
|
||||
"source": "<html><head>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module">import { b as bootstrap } from './app-01141b67.js';
|
||||
|
||||
bootstrap(document.getElementById('root'), "<none>");
|
||||
//# sourceMappingURL=index.body.script.js-45303f0f.js.map
|
||||
</script>
|
||||
|
||||
|
||||
</body></html>",
|
||||
},
|
||||
]
|
||||
`;
|
||||
@ -1,131 +0,0 @@
|
||||
# Snapshot report for `test/multi-entry/test.js`
|
||||
|
||||
The actual snapshot is saved in `test.js.snap`.
|
||||
|
||||
Generated by [AVA](https://avajs.dev).
|
||||
|
||||
## multi-entry
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
[
|
||||
{
|
||||
code: `const b = ()=>'batman';␊
|
||||
console.log(b());␊
|
||||
␊
|
||||
export { b };␊
|
||||
//# sourceMappingURL=batman-c7fa228c.js.map␊
|
||||
`,
|
||||
fileName: 'admin/batman-c7fa228c.js',
|
||||
map: SourceMap {
|
||||
file: 'batman-c7fa228c.js',
|
||||
mappings: 'AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;',
|
||||
names: [],
|
||||
sources: [
|
||||
'../../admin/batman.js',
|
||||
],
|
||||
sourcesContent: [
|
||||
`export const b = ()=>'batman';␊
|
||||
console.log(b());␊
|
||||
`,
|
||||
],
|
||||
version: 3,
|
||||
},
|
||||
source: undefined,
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'admin/batman-c7fa228c.js.map',
|
||||
map: undefined,
|
||||
source: '{"version":3,"file":"batman-c7fa228c.js","sources":["../../admin/batman.js"],"sourcesContent":["export const b = ()=>\'batman\';\\nconsole.log(b());\\n"],"names":[],"mappings":"AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;"}',
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'admin/index.body.script0.js-15dfaff3.js.map',
|
||||
map: undefined,
|
||||
source: '{"version":3,"file":"index.body.script0.js-15dfaff3.js","sources":["../../app/admin-deps.js","../../admin/index.html.body.script0.js"],"sourcesContent":["export function adminDeps(){\\n return \\"robin!\\";\\n}\\n","\\n import {bootstrap} from \\"../app/app.js\\"\\n import {adminDeps} from \\"../app/admin-deps.js\\";\\n bootstrap(document.getElementById(\'root\'), adminDeps());\\n "],"names":[],"mappings":";;AAAO,SAAS,SAAS,EAAE;AAC3B,IAAI,OAAO,QAAQ,CAAC;AACpB;;ACCY,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC"}',
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'admin/index.html',
|
||||
map: undefined,
|
||||
source: `<html><head>␊
|
||||
</head>␊
|
||||
<body>␊
|
||||
<div id="root"></div>␊
|
||||
<script type="module">import { b as bootstrap } from '../app-01141b67.js';␊
|
||||
␊
|
||||
function adminDeps(){␊
|
||||
return "robin!";␊
|
||||
}␊
|
||||
␊
|
||||
bootstrap(document.getElementById('root'), adminDeps());␊
|
||||
//# sourceMappingURL=index.body.script0.js-15dfaff3.js.map␊
|
||||
</script>␊
|
||||
<script src="batman-c7fa228c.js" type="module"></script>␊
|
||||
␊
|
||||
␊
|
||||
</body></html>`,
|
||||
},
|
||||
{
|
||||
code: `const bootstrap = (el,deps = [])=>{␊
|
||||
el.innerHtml = \`␊
|
||||
<div>I'm "annoying" ${"in case we need to test \\\`string\\\` escaping."}. Hence this file \\'tries\\' to include all allowed forms of 'it'</div>␊
|
||||
<div>Deps: ${deps}</div>␊
|
||||
\`;␊
|
||||
};␊
|
||||
␊
|
||||
export { bootstrap as b };␊
|
||||
//# sourceMappingURL=app-01141b67.js.map␊
|
||||
`,
|
||||
fileName: 'app-01141b67.js',
|
||||
map: SourceMap {
|
||||
file: 'app-01141b67.js',
|
||||
mappings: 'AAAY,MAAC,SAAS,GAAG,CAAC,EAAE,CAAC,IAAI,GAAG,EAAE,GAAG;AACzC,IAAI,EAAE,CAAC,SAAS,GAAG,CAAC;AACpB,4BAA4B,EAAE,8CAA8C,CAAC;AAC7E,mBAAmB,EAAE,IAAI,CAAC;AAC1B,IAAI,CAAC,CAAC;AACN;;;;',
|
||||
names: [],
|
||||
sources: [
|
||||
'../app/app.js',
|
||||
],
|
||||
sourcesContent: [
|
||||
`export const bootstrap = (el,deps = [])=>{␊
|
||||
el.innerHtml = \`␊
|
||||
<div>I'm "annoying" ${"in case we need to test \\\`string\\\` escaping."}. Hence this file \\'tries\\' to include all allowed forms of 'it'</div>␊
|
||||
<div>Deps: ${deps}</div>␊
|
||||
\`;␊
|
||||
}␊
|
||||
`,
|
||||
],
|
||||
version: 3,
|
||||
},
|
||||
source: undefined,
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'app-01141b67.js.map',
|
||||
map: undefined,
|
||||
source: '{"version":3,"file":"app-01141b67.js","sources":["../app/app.js"],"sourcesContent":["export const bootstrap = (el,deps = [])=>{\\n el.innerHtml = `\\n <div>I\'m \\"annoying\\" ${\\"in case we need to test \\\\`string\\\\` escaping.\\"}. Hence this file \\\\\'tries\\\\\' to include all allowed forms of \'it\'</div>\\n <div>Deps: ${deps}</div>\\n `;\\n}\\n"],"names":[],"mappings":"AAAY,MAAC,SAAS,GAAG,CAAC,EAAE,CAAC,IAAI,GAAG,EAAE,GAAG;AACzC,IAAI,EAAE,CAAC,SAAS,GAAG,CAAC;AACpB,4BAA4B,EAAE,8CAA8C,CAAC;AAC7E,mBAAmB,EAAE,IAAI,CAAC;AAC1B,IAAI,CAAC,CAAC;AACN;;;;"}',
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'index.body.script.js-45303f0f.js.map',
|
||||
map: undefined,
|
||||
source: '{"version":3,"file":"index.body.script.js-45303f0f.js","sources":["../index.html.body.script.js"],"sourcesContent":["\\n import {bootstrap} from \\"./app/app.js\\"\\n bootstrap(document.getElementById(\'root\'), \\"<none>\\");\\n "],"names":[],"mappings":";;AAEY,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC"}',
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'index.html',
|
||||
map: undefined,
|
||||
source: `<html><head>␊
|
||||
</head>␊
|
||||
<body>␊
|
||||
<div id="root"></div>␊
|
||||
<script type="module">import { b as bootstrap } from './app-01141b67.js';␊
|
||||
␊
|
||||
bootstrap(document.getElementById('root'), "<none>");␊
|
||||
//# sourceMappingURL=index.body.script.js-45303f0f.js.map␊
|
||||
</script>␊
|
||||
␊
|
||||
␊
|
||||
</body></html>`,
|
||||
},
|
||||
]
|
||||
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
import {resolve, join, dirname} from "node:path";
|
||||
import {test, expect} from "@jest/globals";
|
||||
|
||||
import test from "ava";
|
||||
import { rollup } from "rollup";
|
||||
import {debugPrintOutput, getCode} from "../util/index.ts";
|
||||
|
||||
@ -17,7 +17,7 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
process.chdir(join(__dirname, 'fixtures'));
|
||||
|
||||
|
||||
test.serial('multi-entry', async (t) => {
|
||||
test('multi-entry', async () => {
|
||||
const bundle = await rollup({
|
||||
input: {
|
||||
['index']: 'index.html',
|
||||
@ -30,7 +30,7 @@ test.serial('multi-entry', async (t) => {
|
||||
});
|
||||
const code = await getCode(bundle, output);
|
||||
debugPrintOutput('multi-entry',code);
|
||||
t.snapshot(code);
|
||||
expect(code).toMatchSnapshot();
|
||||
});
|
||||
|
||||
// TODO various parameters
|
||||
|
||||
68
test/rewrite-url/__snapshots__/test.js.snap
Normal file
68
test/rewrite-url/__snapshots__/test.js.snap
Normal file
@ -0,0 +1,68 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`rewrite-url 1`] = `
|
||||
[
|
||||
{
|
||||
"code": "const bootstrap = (el,deps = [])=>{
|
||||
el.innerHtml = \`
|
||||
<div>load the app</div>
|
||||
\`;
|
||||
};
|
||||
|
||||
export { bootstrap };
|
||||
//# sourceMappingURL=app-88ed8fd6.js.map
|
||||
",
|
||||
"fileName": "admin/app-88ed8fd6.js",
|
||||
"map": SourceMap {
|
||||
"file": "app-88ed8fd6.js",
|
||||
"mappings": "AAAY,MAAC,SAAS,GAAG,CAAC,EAAE,CAAC,IAAI,GAAG,EAAE,GAAG;AACzC,IAAI,EAAE,CAAC,SAAS,GAAG,CAAC;AACpB;AACA,IAAI,CAAC,CAAC;AACN;;;;",
|
||||
"names": [],
|
||||
"sources": [
|
||||
"../../admin/app.js",
|
||||
],
|
||||
"sourcesContent": [
|
||||
"export const bootstrap = (el,deps = [])=>{
|
||||
el.innerHtml = \`
|
||||
<div>load the app</div>
|
||||
\`;
|
||||
}
|
||||
",
|
||||
],
|
||||
"version": 3,
|
||||
},
|
||||
"source": undefined,
|
||||
},
|
||||
{
|
||||
"code": undefined,
|
||||
"fileName": "admin/app-88ed8fd6.js.map",
|
||||
"map": undefined,
|
||||
"source": "{"version":3,"file":"app-88ed8fd6.js","sources":["../../admin/app.js"],"sourcesContent":["export const bootstrap = (el,deps = [])=>{\\n el.innerHtml = \`\\n <div>load the app</div>\\n \`;\\n}\\n"],"names":[],"mappings":"AAAY,MAAC,SAAS,GAAG,CAAC,EAAE,CAAC,IAAI,GAAG,EAAE,GAAG;AACzC,IAAI,EAAE,CAAC,SAAS,GAAG,CAAC;AACpB;AACA,IAAI,CAAC,CAAC;AACN;;;;"}",
|
||||
},
|
||||
{
|
||||
"code": undefined,
|
||||
"fileName": "admin/index.html",
|
||||
"map": undefined,
|
||||
"source": "<html><head>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script src="/admin/app-88ed8fd6.js" type="module"></script>
|
||||
|
||||
|
||||
</body></html>",
|
||||
},
|
||||
{
|
||||
"code": undefined,
|
||||
"fileName": "index.html",
|
||||
"map": undefined,
|
||||
"source": "<html><head>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script src="/admin/app-88ed8fd6.js" type="module"></script>
|
||||
|
||||
|
||||
</body></html>",
|
||||
},
|
||||
]
|
||||
`;
|
||||
@ -1,74 +0,0 @@
|
||||
# Snapshot report for `test/rewrite-url/test.js`
|
||||
|
||||
The actual snapshot is saved in `test.js.snap`.
|
||||
|
||||
Generated by [AVA](https://avajs.dev).
|
||||
|
||||
## rewrite-url
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
[
|
||||
{
|
||||
code: `const bootstrap = (el,deps = [])=>{␊
|
||||
el.innerHtml = \`␊
|
||||
<div>load the app</div>␊
|
||||
\`;␊
|
||||
};␊
|
||||
␊
|
||||
export { bootstrap };␊
|
||||
//# sourceMappingURL=app-88ed8fd6.js.map␊
|
||||
`,
|
||||
fileName: 'admin/app-88ed8fd6.js',
|
||||
map: SourceMap {
|
||||
file: 'app-88ed8fd6.js',
|
||||
mappings: 'AAAY,MAAC,SAAS,GAAG,CAAC,EAAE,CAAC,IAAI,GAAG,EAAE,GAAG;AACzC,IAAI,EAAE,CAAC,SAAS,GAAG,CAAC;AACpB;AACA,IAAI,CAAC,CAAC;AACN;;;;',
|
||||
names: [],
|
||||
sources: [
|
||||
'../../admin/app.js',
|
||||
],
|
||||
sourcesContent: [
|
||||
`export const bootstrap = (el,deps = [])=>{␊
|
||||
el.innerHtml = \`␊
|
||||
<div>load the app</div>␊
|
||||
\`;␊
|
||||
}␊
|
||||
`,
|
||||
],
|
||||
version: 3,
|
||||
},
|
||||
source: undefined,
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'admin/app-88ed8fd6.js.map',
|
||||
map: undefined,
|
||||
source: '{"version":3,"file":"app-88ed8fd6.js","sources":["../../admin/app.js"],"sourcesContent":["export const bootstrap = (el,deps = [])=>{\\n el.innerHtml = `\\n <div>load the app</div>\\n `;\\n}\\n"],"names":[],"mappings":"AAAY,MAAC,SAAS,GAAG,CAAC,EAAE,CAAC,IAAI,GAAG,EAAE,GAAG;AACzC,IAAI,EAAE,CAAC,SAAS,GAAG,CAAC;AACpB;AACA,IAAI,CAAC,CAAC;AACN;;;;"}',
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'admin/index.html',
|
||||
map: undefined,
|
||||
source: `<html><head>␊
|
||||
</head>␊
|
||||
<body>␊
|
||||
<div id="root"></div>␊
|
||||
<script src="/admin/app-88ed8fd6.js" type="module"></script>␊
|
||||
␊
|
||||
␊
|
||||
</body></html>`,
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'index.html',
|
||||
map: undefined,
|
||||
source: `<html><head>␊
|
||||
</head>␊
|
||||
<body>␊
|
||||
<div id="root"></div>␊
|
||||
<script src="/admin/app-88ed8fd6.js" type="module"></script>␊
|
||||
␊
|
||||
␊
|
||||
</body></html>`,
|
||||
},
|
||||
]
|
||||
Binary file not shown.
@ -1,5 +1,6 @@
|
||||
import {resolve, join, dirname} from "node:path";
|
||||
import test from "ava";
|
||||
import {test, expect} from "@jest/globals";
|
||||
|
||||
import {runBrowserTest} from "../util/index.ts";
|
||||
|
||||
import html from "../../src/index.ts";
|
||||
@ -9,8 +10,7 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
process.chdir(join(__dirname, 'fixtures'));
|
||||
|
||||
|
||||
test.serial('rewrite-url', async (t) => {
|
||||
|
||||
test('rewrite-url', async () => {
|
||||
const out = await runBrowserTest({
|
||||
input: {
|
||||
['index']: 'index.html',
|
||||
@ -25,7 +25,6 @@ test.serial('rewrite-url', async (t) => {
|
||||
}),
|
||||
],
|
||||
},{
|
||||
log: t.log,
|
||||
filterOutput:{
|
||||
// TODO: Currently only need the "await getCode(bundle, output);" as output
|
||||
},
|
||||
@ -35,8 +34,7 @@ test.serial('rewrite-url', async (t) => {
|
||||
format: 'es', // iifi and cjs should be added to tests
|
||||
sourcemap: true,// Test if #sourcemapUrl is not accidentally included in the html-output
|
||||
});
|
||||
|
||||
t.snapshot(out.code); // Snapshot the result code
|
||||
expect(out.code).toMatchSnapshot(); // Snapshot the result code
|
||||
|
||||
// const bundle = await rollup({
|
||||
// input: {
|
||||
|
||||
2
test/setup.js
Normal file
2
test/setup.js
Normal file
@ -0,0 +1,2 @@
|
||||
// Replace the jest console with the normal one (jest makes console.log too verbose)
|
||||
global.console = await import("node:console");
|
||||
49
test/templating/__snapshots__/test.js.snap
Normal file
49
test/templating/__snapshots__/test.js.snap
Normal file
@ -0,0 +1,49 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`handlebars 1`] = `
|
||||
[
|
||||
{
|
||||
"code": "const b = ()=>'batman';
|
||||
console.log(b());
|
||||
|
||||
export { b };
|
||||
//# sourceMappingURL=batman-c7fa228c.js.map
|
||||
",
|
||||
"fileName": "batman-c7fa228c.js",
|
||||
"map": SourceMap {
|
||||
"file": "batman-c7fa228c.js",
|
||||
"mappings": "AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;",
|
||||
"names": [],
|
||||
"sources": [
|
||||
"../batman.js",
|
||||
],
|
||||
"sourcesContent": [
|
||||
"export const b = ()=>'batman';
|
||||
console.log(b());
|
||||
",
|
||||
],
|
||||
"version": 3,
|
||||
},
|
||||
"source": undefined,
|
||||
},
|
||||
{
|
||||
"code": undefined,
|
||||
"fileName": "batman-c7fa228c.js.map",
|
||||
"map": undefined,
|
||||
"source": "{"version":3,"file":"batman-c7fa228c.js","sources":["../batman.js"],"sourcesContent":["export const b = ()=>'batman';\\nconsole.log(b());\\n"],"names":[],"mappings":"AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;"}",
|
||||
},
|
||||
{
|
||||
"code": undefined,
|
||||
"fileName": "index.html",
|
||||
"map": undefined,
|
||||
"source": "<html><head>
|
||||
<meta data-test="a">
|
||||
</head>
|
||||
<body>
|
||||
<script src="batman-c7fa228c.js" type="module"></script>
|
||||
|
||||
|
||||
</body></html>",
|
||||
},
|
||||
]
|
||||
`;
|
||||
@ -1,55 +0,0 @@
|
||||
# Snapshot report for `test/templating/test.js`
|
||||
|
||||
The actual snapshot is saved in `test.js.snap`.
|
||||
|
||||
Generated by [AVA](https://avajs.dev).
|
||||
|
||||
## handlebars
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
[
|
||||
{
|
||||
code: `const b = ()=>'batman';␊
|
||||
console.log(b());␊
|
||||
␊
|
||||
export { b };␊
|
||||
//# sourceMappingURL=batman-c7fa228c.js.map␊
|
||||
`,
|
||||
fileName: 'batman-c7fa228c.js',
|
||||
map: SourceMap {
|
||||
file: 'batman-c7fa228c.js',
|
||||
mappings: 'AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;',
|
||||
names: [],
|
||||
sources: [
|
||||
'../batman.js',
|
||||
],
|
||||
sourcesContent: [
|
||||
`export const b = ()=>'batman';␊
|
||||
console.log(b());␊
|
||||
`,
|
||||
],
|
||||
version: 3,
|
||||
},
|
||||
source: undefined,
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'batman-c7fa228c.js.map',
|
||||
map: undefined,
|
||||
source: '{"version":3,"file":"batman-c7fa228c.js","sources":["../batman.js"],"sourcesContent":["export const b = ()=>\'batman\';\\nconsole.log(b());\\n"],"names":[],"mappings":"AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;"}',
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'index.html',
|
||||
map: undefined,
|
||||
source: `<html><head>␊
|
||||
<meta data-test="a">␊
|
||||
</head>␊
|
||||
<body>␊
|
||||
<script src="batman-c7fa228c.js" type="module"></script>␊
|
||||
␊
|
||||
␊
|
||||
</body></html>`,
|
||||
},
|
||||
]
|
||||
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
import {join, dirname} from "node:path";
|
||||
import {test, expect} from "@jest/globals";
|
||||
|
||||
import test from "ava";
|
||||
import { rollup } from "rollup";
|
||||
|
||||
import {debugPrintOutput, getCode} from "../util/index.ts";
|
||||
@ -18,8 +18,7 @@ import {fileURLToPath} from "node:url";
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
process.chdir(join(__dirname, 'fixtures'));
|
||||
|
||||
|
||||
test.serial('handlebars', async (t) => {
|
||||
test('handlebars', async () => {
|
||||
const bundle = await rollup({
|
||||
input: 'index.hbs',
|
||||
plugins: [
|
||||
@ -32,7 +31,7 @@ test.serial('handlebars', async (t) => {
|
||||
});
|
||||
const code = await getCode(bundle, output);
|
||||
debugPrintOutput('handlebars',code);
|
||||
t.snapshot(code);
|
||||
expect(code).toMatchSnapshot();
|
||||
});
|
||||
|
||||
|
||||
|
||||
97
test/url-plugin/__snapshots__/test.js.snap
Normal file
97
test/url-plugin/__snapshots__/test.js.snap
Normal file
@ -0,0 +1,97 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`url-plugin copied-assets 1`] = `
|
||||
[
|
||||
{
|
||||
"code": "const b = ()=>'batman';
|
||||
console.log(b());
|
||||
|
||||
export { b };
|
||||
//# sourceMappingURL=batman-c7fa228c.js.map
|
||||
",
|
||||
"fileName": "batman-c7fa228c.js",
|
||||
"map": SourceMap {
|
||||
"file": "batman-c7fa228c.js",
|
||||
"mappings": "AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;",
|
||||
"names": [],
|
||||
"sources": [
|
||||
"../batman.js",
|
||||
],
|
||||
"sourcesContent": [
|
||||
"export const b = ()=>'batman';
|
||||
console.log(b());
|
||||
",
|
||||
],
|
||||
"version": 3,
|
||||
},
|
||||
"source": undefined,
|
||||
},
|
||||
{
|
||||
"code": undefined,
|
||||
"fileName": "batman-c7fa228c.js.map",
|
||||
"map": undefined,
|
||||
"source": "{"version":3,"file":"batman-c7fa228c.js","sources":["../batman.js"],"sourcesContent":["export const b = ()=>'batman';\\nconsole.log(b());\\n"],"names":[],"mappings":"AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;"}",
|
||||
},
|
||||
{
|
||||
"code": undefined,
|
||||
"fileName": "index.html",
|
||||
"map": undefined,
|
||||
"source": "<html><head>
|
||||
<link rel="icon" href="fb585fdb6db313c9.svg">
|
||||
</head>
|
||||
<body>
|
||||
<script src="batman-c7fa228c.js" type="module"></script>
|
||||
|
||||
|
||||
</body></html>",
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`url-plugin inlined-assets 1`] = `
|
||||
[
|
||||
{
|
||||
"code": "const b = ()=>'batman';
|
||||
console.log(b());
|
||||
|
||||
export { b };
|
||||
//# sourceMappingURL=batman-c7fa228c.js.map
|
||||
",
|
||||
"fileName": "batman-c7fa228c.js",
|
||||
"map": SourceMap {
|
||||
"file": "batman-c7fa228c.js",
|
||||
"mappings": "AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;",
|
||||
"names": [],
|
||||
"sources": [
|
||||
"../batman.js",
|
||||
],
|
||||
"sourcesContent": [
|
||||
"export const b = ()=>'batman';
|
||||
console.log(b());
|
||||
",
|
||||
],
|
||||
"version": 3,
|
||||
},
|
||||
"source": undefined,
|
||||
},
|
||||
{
|
||||
"code": undefined,
|
||||
"fileName": "batman-c7fa228c.js.map",
|
||||
"map": undefined,
|
||||
"source": "{"version":3,"file":"batman-c7fa228c.js","sources":["../batman.js"],"sourcesContent":["export const b = ()=>'batman';\\nconsole.log(b());\\n"],"names":[],"mappings":"AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;"}",
|
||||
},
|
||||
{
|
||||
"code": undefined,
|
||||
"fileName": "index.html",
|
||||
"map": undefined,
|
||||
"source": "<html><head>
|
||||
<link rel="icon" href="data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%2032%2032%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%20%20%3Cpath%20style%3D%22fill%3Anone%3Bstroke%3A%2300ff0d%3Bstroke-width%3A5%3Bstroke-linecap%3Asquare%3Bstroke-linejoin%3Amiter%3Bstroke-dasharray%3Anone%3Bstroke-opacity%3A1%22%20d%3D%22M4.1%2014.72%2016%2026.31%2028.38%205.09%22%2F%3E%3C%2Fsvg%3E">
|
||||
</head>
|
||||
<body>
|
||||
<script src="batman-c7fa228c.js" type="module"></script>
|
||||
|
||||
|
||||
</body></html>",
|
||||
},
|
||||
]
|
||||
`;
|
||||
@ -1,105 +0,0 @@
|
||||
# Snapshot report for `test/url-plugin/test.js`
|
||||
|
||||
The actual snapshot is saved in `test.js.snap`.
|
||||
|
||||
Generated by [AVA](https://avajs.dev).
|
||||
|
||||
## copied-assets
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
[
|
||||
{
|
||||
code: `const b = ()=>'batman';␊
|
||||
console.log(b());␊
|
||||
␊
|
||||
export { b };␊
|
||||
//# sourceMappingURL=batman-c7fa228c.js.map␊
|
||||
`,
|
||||
fileName: 'batman-c7fa228c.js',
|
||||
map: SourceMap {
|
||||
file: 'batman-c7fa228c.js',
|
||||
mappings: 'AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;',
|
||||
names: [],
|
||||
sources: [
|
||||
'../batman.js',
|
||||
],
|
||||
sourcesContent: [
|
||||
`export const b = ()=>'batman';␊
|
||||
console.log(b());␊
|
||||
`,
|
||||
],
|
||||
version: 3,
|
||||
},
|
||||
source: undefined,
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'batman-c7fa228c.js.map',
|
||||
map: undefined,
|
||||
source: '{"version":3,"file":"batman-c7fa228c.js","sources":["../batman.js"],"sourcesContent":["export const b = ()=>\'batman\';\\nconsole.log(b());\\n"],"names":[],"mappings":"AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;"}',
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'index.html',
|
||||
map: undefined,
|
||||
source: `<html><head>␊
|
||||
<link rel="icon" href="fb585fdb6db313c9.svg">␊
|
||||
</head>␊
|
||||
<body>␊
|
||||
<script src="batman-c7fa228c.js" type="module"></script>␊
|
||||
␊
|
||||
␊
|
||||
</body></html>`,
|
||||
},
|
||||
]
|
||||
|
||||
## inlined-assets
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
[
|
||||
{
|
||||
code: `const b = ()=>'batman';␊
|
||||
console.log(b());␊
|
||||
␊
|
||||
export { b };␊
|
||||
//# sourceMappingURL=batman-c7fa228c.js.map␊
|
||||
`,
|
||||
fileName: 'batman-c7fa228c.js',
|
||||
map: SourceMap {
|
||||
file: 'batman-c7fa228c.js',
|
||||
mappings: 'AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;',
|
||||
names: [],
|
||||
sources: [
|
||||
'../batman.js',
|
||||
],
|
||||
sourcesContent: [
|
||||
`export const b = ()=>'batman';␊
|
||||
console.log(b());␊
|
||||
`,
|
||||
],
|
||||
version: 3,
|
||||
},
|
||||
source: undefined,
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'batman-c7fa228c.js.map',
|
||||
map: undefined,
|
||||
source: '{"version":3,"file":"batman-c7fa228c.js","sources":["../batman.js"],"sourcesContent":["export const b = ()=>\'batman\';\\nconsole.log(b());\\n"],"names":[],"mappings":"AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;"}',
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'index.html',
|
||||
map: undefined,
|
||||
source: `<html><head>␊
|
||||
<link rel="icon" href="data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%2032%2032%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%20%20%3Cpath%20style%3D%22fill%3Anone%3Bstroke%3A%2300ff0d%3Bstroke-width%3A5%3Bstroke-linecap%3Asquare%3Bstroke-linejoin%3Amiter%3Bstroke-dasharray%3Anone%3Bstroke-opacity%3A1%22%20d%3D%22M4.1%2014.72%2016%2026.31%2028.38%205.09%22%2F%3E%3C%2Fsvg%3E">␊
|
||||
</head>␊
|
||||
<body>␊
|
||||
<script src="batman-c7fa228c.js" type="module"></script>␊
|
||||
␊
|
||||
␊
|
||||
</body></html>`,
|
||||
},
|
||||
]
|
||||
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
import {join, dirname} from "node:path";
|
||||
import {test, expect} from "@jest/globals";
|
||||
|
||||
import test from "ava";
|
||||
import { rollup } from "rollup";
|
||||
import urlPlugin from "@rollup/plugin-url";
|
||||
|
||||
@ -25,40 +25,43 @@ const defaultAssetInclude = [
|
||||
'**/*.(webm|mp4)',// video
|
||||
];
|
||||
|
||||
test.serial('copied-assets', async (t) => {
|
||||
const bundle = await rollup({
|
||||
input: 'index.html',
|
||||
plugins: [
|
||||
html({
|
||||
}),
|
||||
urlPlugin({
|
||||
include: defaultAssetInclude,
|
||||
limit: 0,// Never inline something
|
||||
}),
|
||||
],
|
||||
describe("url-plugin", ()=>{
|
||||
test('copied-assets', async () => {
|
||||
const bundle = await rollup({
|
||||
input: 'index.html',
|
||||
plugins: [
|
||||
html({
|
||||
}),
|
||||
urlPlugin({
|
||||
include: defaultAssetInclude,
|
||||
limit: 0,// Never inline something
|
||||
}),
|
||||
],
|
||||
});
|
||||
const code = await getCode(bundle, output);
|
||||
debugPrintOutput('copied-assets',code);
|
||||
expect(code).toMatchSnapshot();
|
||||
});
|
||||
const code = await getCode(bundle, output);
|
||||
debugPrintOutput('copied-assets',code);
|
||||
t.snapshot(code);
|
||||
});
|
||||
|
||||
|
||||
test.serial('inlined-assets', async (t) => {
|
||||
const bundle = await rollup({
|
||||
input: 'index.html',
|
||||
plugins: [
|
||||
html({
|
||||
}),
|
||||
urlPlugin({
|
||||
include: defaultAssetInclude,
|
||||
limit: Number.MAX_SAFE_INTEGER,// Always inline things
|
||||
}),
|
||||
]
|
||||
test('inlined-assets', async () => {
|
||||
const bundle = await rollup({
|
||||
input: 'index.html',
|
||||
plugins: [
|
||||
html({
|
||||
}),
|
||||
urlPlugin({
|
||||
include: defaultAssetInclude,
|
||||
limit: Number.MAX_SAFE_INTEGER,// Always inline things
|
||||
}),
|
||||
]
|
||||
});
|
||||
const code = await getCode(bundle, output);
|
||||
debugPrintOutput('inlined-assets',code);
|
||||
expect(code).toMatchSnapshot();
|
||||
});
|
||||
const code = await getCode(bundle, output);
|
||||
debugPrintOutput('inlined-assets',code);
|
||||
t.snapshot(code);
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
// TODO various parameters
|
||||
// - format: cjs, iifi, ...
|
||||
|
||||
@ -1,65 +1,10 @@
|
||||
import {Plugin, InputPluginOption, RollupOptions, OutputOptions, RollupOutput} from "rollup";
|
||||
import {TestOptions as BrowserTestOptions, TestOutput as PuppeteerTestOutput} from "./puppeteer-run-test.js";
|
||||
import { rollup } from "rollup";
|
||||
import serveTest, {LogCallback} from "./serve-test.js";
|
||||
import serveTest, {LogCallback} from "./serve-test.ts";
|
||||
import type {ExecutionContext} from "ava";
|
||||
import {getCode, TestOutput} from "./code-output.ts";
|
||||
|
||||
|
||||
// /**
|
||||
// * The AVA context used to test (ie t.snapshot(..) )
|
||||
// */
|
||||
// t: ExecutionContext
|
||||
//
|
||||
//
|
||||
// filterOutput:{
|
||||
// html: true,
|
||||
// console: ['log','error','warn'],// TODO: or warning? need to check what possible values are
|
||||
// errors: true, // again don't know possible values
|
||||
// responses: true, // interesting to see what other values were requested
|
||||
// requestsFailed: true, // will probably also be replicated into console errors, but helpful to have if imports werent found
|
||||
// }
|
||||
|
||||
|
||||
// try{
|
||||
// // Track requests, errors and console
|
||||
// page.on('console', message => {
|
||||
// let [type, text] = [message.type(), message.text()];
|
||||
// if(replaceHost){
|
||||
// text = text.replaceAll(hostUrl, replaceHostWith!);
|
||||
// }
|
||||
// if((<any>filterOutput.console)?.includes?.(<any>type) ?? (filterOutput.console === true)){// TODO: add callback option
|
||||
// output.console?.push(`[${type}] ${text}`);
|
||||
// }
|
||||
// }).on('pageerror', ({ message }) => {
|
||||
// let text = message;
|
||||
// if(replaceHost){
|
||||
// text = text.replaceAll(hostUrl, replaceHostWith!);
|
||||
// }
|
||||
// if(filterOutput.errors === true) {// TODO add callback option
|
||||
// output.errors?.push(text)
|
||||
// }
|
||||
// }).on('response', response => {
|
||||
// let [status, url] = [response.status(), response.url()]
|
||||
// if(replaceHost){
|
||||
// url = url.replaceAll(hostUrl, replaceHostWith!);
|
||||
// }
|
||||
// if(filterOutput.responses === true) {// TODO add callback option
|
||||
// output.responses?.push(`${status} ${url}`)
|
||||
// }
|
||||
// }).on('requestfailed', request => {
|
||||
// let [failure, url] = [request.failure()?.errorText, request.url()];
|
||||
// if(replaceHost){
|
||||
// failure = failure?.replaceAll(hostUrl, replaceHostWith!);
|
||||
// url = url.replaceAll(hostUrl, replaceHostWith!);
|
||||
// }
|
||||
// if(filterOutput.requestsFailed === true) {// TODO add callback option
|
||||
// output.requestsFailed?.push(`${failure} ${url}`)
|
||||
// }
|
||||
// });
|
||||
|
||||
// testOptions.t?.snapshot?.(testOutput);
|
||||
|
||||
export interface OutputFilterOptions {
|
||||
html?: boolean
|
||||
console?: ('log'|'error'|'warn')[] | true
|
||||
@ -123,6 +68,7 @@ export async function runBrowserTest(
|
||||
if(output){
|
||||
testOutput.code = await getCode(bundle, output);
|
||||
}
|
||||
await bundle.close();
|
||||
|
||||
return testOutput
|
||||
|
||||
|
||||
47
test/watch/__snapshots__/test.js.snap
Normal file
47
test/watch/__snapshots__/test.js.snap
Normal file
@ -0,0 +1,47 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`watch 1`] = `
|
||||
[
|
||||
{
|
||||
"code": undefined,
|
||||
"fileName": "index.html",
|
||||
"map": undefined,
|
||||
"source": "<html><head>
|
||||
</head>
|
||||
<body>
|
||||
<script src="watched-file.js" type="module"></script>
|
||||
|
||||
|
||||
</body></html>",
|
||||
},
|
||||
{
|
||||
"code": "const a = 2; // If i show up as a changed file, then the watch test has gone wrong!
|
||||
|
||||
export { a };
|
||||
//# sourceMappingURL=watched-file.js.map
|
||||
",
|
||||
"fileName": "watched-file.js",
|
||||
"map": SourceMap {
|
||||
"file": "watched-file.js",
|
||||
"mappings": "AACgB,MAAC,CAAC,GAAG,EAAE;;;;",
|
||||
"names": [],
|
||||
"sources": [
|
||||
"../watched-file.js",
|
||||
],
|
||||
"sourcesContent": [
|
||||
"
|
||||
export const a = 2; // If i show up as a changed file, then the watch test has gone wrong!
|
||||
",
|
||||
],
|
||||
"version": 3,
|
||||
},
|
||||
"source": undefined,
|
||||
},
|
||||
{
|
||||
"code": undefined,
|
||||
"fileName": "watched-file.js.map",
|
||||
"map": undefined,
|
||||
"source": "{"version":3,"file":"watched-file.js","sources":["../watched-file.js"],"sourcesContent":["\\n export const a = 2; // If i show up as a changed file, then the watch test has gone wrong!\\n "],"names":[],"mappings":"AACgB,MAAC,CAAC,GAAG,EAAE;;;;"}",
|
||||
},
|
||||
]
|
||||
`;
|
||||
@ -1,53 +0,0 @@
|
||||
# Snapshot report for `test/watch/test.js`
|
||||
|
||||
The actual snapshot is saved in `test.js.snap`.
|
||||
|
||||
Generated by [AVA](https://avajs.dev).
|
||||
|
||||
## watch
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
[
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'index.html',
|
||||
map: undefined,
|
||||
source: `<html><head>␊
|
||||
</head>␊
|
||||
<body>␊
|
||||
<script src="watched-file-8c4729c5.js" type="module"></script>␊
|
||||
␊
|
||||
␊
|
||||
</body></html>`,
|
||||
},
|
||||
{
|
||||
code: `const a = 2; // If i show up as a changed file, then the watch test has gone wrong!␊
|
||||
␊
|
||||
export { a };␊
|
||||
//# sourceMappingURL=watched-file-8c4729c5.js.map␊
|
||||
`,
|
||||
fileName: 'watched-file-8c4729c5.js',
|
||||
map: SourceMap {
|
||||
file: 'watched-file-8c4729c5.js',
|
||||
mappings: 'AACgB,MAAC,CAAC,GAAG,EAAE;;;;',
|
||||
names: [],
|
||||
sources: [
|
||||
'../watched-file.js',
|
||||
],
|
||||
sourcesContent: [
|
||||
`␊
|
||||
export const a = 2; // If i show up as a changed file, then the watch test has gone wrong!␊
|
||||
`,
|
||||
],
|
||||
version: 3,
|
||||
},
|
||||
source: undefined,
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'watched-file-8c4729c5.js.map',
|
||||
map: undefined,
|
||||
source: '{"version":3,"file":"watched-file-8c4729c5.js","sources":["../watched-file.js"],"sourcesContent":["\\n export const a = 2; // If i show up as a changed file, then the watch test has gone wrong!\\n "],"names":[],"mappings":"AACgB,MAAC,CAAC,GAAG,EAAE;;;;"}',
|
||||
},
|
||||
]
|
||||
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
import {join, dirname} from "node:path";
|
||||
import {test, expect} from "@jest/globals";
|
||||
|
||||
import test from "ava";
|
||||
import * as rollup from "rollup";
|
||||
import {debugPrintOutput, getCode} from "../util/index.ts";
|
||||
import {resolve} from "node:path";
|
||||
@ -12,6 +12,10 @@ const output = {
|
||||
dir: 'output', // Output all files
|
||||
format: 'es', // iifi and cjs should be added to tests
|
||||
sourcemap: true,// Test if #sourcemapUrl is not accidentally included in the html-output
|
||||
// Prevent hashes from being added (and screw up the snapshots)
|
||||
chunkFileNames: '[name].js',
|
||||
entryFileNames: '[name].[extname]',
|
||||
assetFileNames: '[name].[extname]',
|
||||
};
|
||||
|
||||
import {fileURLToPath} from "node:url";
|
||||
@ -20,7 +24,7 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
process.chdir(join(__dirname, 'fixtures'));
|
||||
|
||||
|
||||
test.serial('watch', async (t) => {
|
||||
test('watch', async () => {
|
||||
const origContent = `
|
||||
export const a = 1; // DO NOT CHANGE ME HERE, but in ../test.js
|
||||
`;
|
||||
@ -56,25 +60,26 @@ test.serial('watch', async (t) => {
|
||||
await writeFile(path, origContent, {encoding: 'utf-8'});
|
||||
|
||||
// Assert the output is what we exapect;
|
||||
t.snapshot(code);
|
||||
expect(code).toMatchSnapshot();
|
||||
|
||||
watcher
|
||||
},
|
||||
];
|
||||
const log = console.log;
|
||||
|
||||
await new Promise((resolve, reject)=>{
|
||||
watcher.on('event', async (event) => {
|
||||
const {result} = event;
|
||||
switch (event.code) {
|
||||
case "START":
|
||||
t.log(`WATCH STARTED`);
|
||||
log(`WATCH STARTED`);
|
||||
break;
|
||||
case "BUNDLE_START":
|
||||
t.log(`REBUILDING...`);
|
||||
log(`REBUILDING...`);
|
||||
|
||||
break;
|
||||
case "BUNDLE_END":
|
||||
t.log(`Rebuilt...`);
|
||||
log(`Rebuilt...`);
|
||||
const cb = steps.shift();
|
||||
|
||||
const generated = await result.generate(output);
|
||||
@ -94,4 +99,6 @@ test.serial('watch', async (t) => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
await watcher.close();
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user