chore: update dependencies to rollup 4 and remove unneeded dependencies

This commit is contained in:
Miel Truyen 2024-02-21 00:15:33 +01:00
parent e46f668ac8
commit c4878caef3
23 changed files with 237 additions and 49272 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "rollup-plugin-html-entry2", "name": "rollup-plugin-html-entry2",
"version": "0.0.6", "version": "0.0.7",
"description": "Teaches rollup how to deal with HTML, allows to use HTML-files as entry-points.", "description": "Teaches rollup how to deal with HTML, allows to use HTML-files as entry-points.",
"license": "MIT", "license": "MIT",
"repository": { "repository": {
@ -47,7 +47,7 @@
"template" "template"
], ],
"peerDependencies": { "peerDependencies": {
"rollup": "^3.0.0" "rollup": "^4.0.0"
}, },
"peerDependenciesMeta": { "peerDependenciesMeta": {
"rollup": { "rollup": {
@ -81,12 +81,10 @@
"lint-staged": "^13.3.0", "lint-staged": "^13.3.0",
"nyc": "^15.1.0", "nyc": "^15.1.0",
"postcss": "^8.4.31", "postcss": "^8.4.31",
"rollup": "^3.29.4", "rollup": "^4.12.0",
"rollup-plugin-delete": "^2.0.0", "rollup-plugin-delete": "^2.0.0",
"rollup-plugin-livereload": "^2.0.5", "rollup-plugin-livereload": "^2.0.5",
"rollup-plugin-postcss": "^4.0.2", "rollup-plugin-postcss": "^4.0.2",
"tslib": "^2.6.2",
"tsx": "^4.4.0",
"typescript": "^5.3.2", "typescript": "^5.3.2",
"puppeteer": "^21.5.2", "puppeteer": "^21.5.2",
"mime": "^4.0.0", "mime": "^4.0.0",
@ -101,22 +99,5 @@
"jest": { "jest": {
"preset":"ts-jest/presets/default-esm", "preset":"ts-jest/presets/default-esm",
"setupFiles": ["./test/setup.js"] "setupFiles": ["./test/setup.js"]
},
"ava": {
"workerThreads": false,
"files": [
"!**/fixtures/**",
"!**/util/**",
"!**/helpers/**",
"!**/recipes/**",
"!**/types.ts"
],
"extensions": {
"ts": "module",
"js": true
},
"nodeArguments": [
"--experimental-vm-modules"
]
} }
} }

815
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -99,7 +99,8 @@ export default function html(opts: RollupHtmlOptions = {}): Plugin {
* *
* *
* Rework by testing a stripped down version with JS imports? * Rework by testing a stripped down version with JS imports?
* - the logic in load should be moved to a transform, properly use rollups ability to specify the plugin should run 'pre' other hooks and see if that allows us to intercept before a commonjs or some other tool horribly transpiles our code * - the logic in load should be moved to a transform, properly use rollups ability to specify the plugin should
* run 'pre' other hooks and see if that allows us to intercept before a commonjs or some other tool horribly transpiles our code
* - we might need to know which output is being used to properly extract the html back from the result? (in case of not being included in a JS file) * - we might need to know which output is being used to properly extract the html back from the result? (in case of not being included in a JS file)
*/ */
return { return {
@ -113,9 +114,9 @@ export default function html(opts: RollupHtmlOptions = {}): Plugin {
}, },
resolveId: { resolveId: {
async handler(specifier: string, async handler(specifier,
importer: string | undefined, importer,
options: { assertions: Record<string, string> }){ options){
if(virtualSources.has(specifier)) return specifier; if(virtualSources.has(specifier)) return specifier;
if(!filter(specifier)) return; if(!filter(specifier)) return;
@ -206,6 +207,7 @@ export default function html(opts: RollupHtmlOptions = {}): Plugin {
virtualSources.set(sourceId, source); virtualSources.set(sourceId, source);
} }
const resolved = await this.resolve(sourceId, id, { const resolved = await this.resolve(sourceId, id, {
skipSelf: false, // defaults to true since rollup 4, and for virtual files this is problematic
isEntry: type==='entryChunk', isEntry: type==='entryChunk',
}); });
if(!resolved){ if(!resolved){

View File

@ -4,9 +4,9 @@ exports[`basic inline-script 1`] = `
[ [
{ {
"code": undefined, "code": undefined,
"fileName": "script.body.script.js-e3b82208.js.map", "fileName": "script.body.script.js.js.map",
"map": undefined, "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"}", "source": "{"version":3,"file":"script.body.script.js.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, "code": undefined,
@ -21,7 +21,7 @@ console.log(b());
document.body.appendChild( document.body.appendChild(
document.createTextNode(\`Inline script including \${b()}\`) document.createTextNode(\`Inline script including \${b()}\`)
); );
//# sourceMappingURL=script.body.script.js-e3b82208.js.map //# sourceMappingURL=script.body.script.js.js.map
</script> </script>
@ -37,11 +37,11 @@ exports[`basic simple 1`] = `
console.log(b()); console.log(b());
export { b }; export { b };
//# sourceMappingURL=batman-c7fa228c.js.map //# sourceMappingURL=batman.js.map
", ",
"fileName": "batman-c7fa228c.js", "fileName": "batman.js",
"map": SourceMap { "map": SourceMap {
"file": "batman-c7fa228c.js", "file": "batman.js",
"mappings": "AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;", "mappings": "AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;",
"names": [], "names": [],
"sources": [ "sources": [
@ -58,9 +58,9 @@ console.log(b());
}, },
{ {
"code": undefined, "code": undefined,
"fileName": "batman-c7fa228c.js.map", "fileName": "batman.js.map",
"map": undefined, "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;;;;"}", "source": "{"version":3,"file":"batman.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, "code": undefined,
@ -69,7 +69,7 @@ console.log(b());
"source": "<html><head> "source": "<html><head>
</head> </head>
<body> <body>
<script src="batman-c7fa228c.js" type="module"></script> <script src="batman.js" type="module"></script>
</body></html>", </body></html>",

View File

@ -7,12 +7,6 @@ import {debugPrintOutput, getCode} from "../util/index.ts";
import html from "../../src/index.ts"; import html from "../../src/index.ts";
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
};
import {fileURLToPath} from "node:url"; import {fileURLToPath} from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url)); const __dirname = dirname(fileURLToPath(import.meta.url));
process.chdir(join(__dirname, 'fixtures')); process.chdir(join(__dirname, 'fixtures'));
@ -25,7 +19,7 @@ describe("basic", ()=> {
html({}), html({}),
] ]
}); });
const code = await getCode(bundle, output); const code = await getCode(bundle);
await bundle.close(); await bundle.close();
debugPrintOutput('simple', code); debugPrintOutput('simple', code);
expect(code).toMatchSnapshot(); expect(code).toMatchSnapshot();
@ -38,7 +32,7 @@ describe("basic", ()=> {
html({}), html({}),
] ]
}); });
const code = await getCode(bundle, output); const code = await getCode(bundle);
await bundle.close(); await bundle.close();
debugPrintOutput('inline-script', code); debugPrintOutput('inline-script', code);
expect(code).toMatchSnapshot(); expect(code).toMatchSnapshot();

View File

@ -2,160 +2,6 @@
exports[`evaluated-web-bundle 1`] = ` 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": [ "console": [
"[log] Bootstrapped, ready to go!", "[log] Bootstrapped, ready to go!",
"[log] Test my sourcemap: App started", "[log] Test my sourcemap: App started",

View File

@ -22,11 +22,11 @@ function render(){
} }
export { render }; export { render };
//# sourceMappingURL=index-3d1ca61b.js.map //# sourceMappingURL=index.js.map
", ",
"fileName": "index-3d1ca61b.js", "fileName": "index.js",
"map": SourceMap { "map": SourceMap {
"file": "index-3d1ca61b.js", "file": "index.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;;;;", "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": [], "names": [],
"sources": [ "sources": [
@ -61,9 +61,9 @@ export function render(){
}, },
{ {
"code": undefined, "code": undefined,
"fileName": "index-3d1ca61b.js.map", "fileName": "index.js.map",
"map": undefined, "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;;;;"}", "source": "{"version":3,"file":"index.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;;;;"}",
}, },
] ]
`; `;

View File

@ -8,11 +8,6 @@ import {debugPrintOutput, getCode} from "../util/index.ts";
import html from "../../src/index.ts"; import html from "../../src/index.ts";
import handlebars from "handlebars"; import handlebars from "handlebars";
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
};
import {fileURLToPath} from "node:url"; import {fileURLToPath} from "node:url";
import urlPlugin from "@rollup/plugin-url"; import urlPlugin from "@rollup/plugin-url";
@ -39,7 +34,7 @@ test('js-import', async () => {
}), }),
] ]
}); });
const code = await getCode(bundle, output); const code = await getCode(bundle);
debugPrintOutput('js-import',code); debugPrintOutput('js-import',code);
expect(code).toMatchSnapshot(); expect(code).toMatchSnapshot();
}); });

File diff suppressed because one or more lines are too long

View File

@ -11,11 +11,11 @@ const test = ()=>{
console.log(test()); console.log(test());
export { test }; export { test };
//# sourceMappingURL=batman-1a5fc364.js.map //# sourceMappingURL=batman.js.map
", ",
"fileName": "batman-1a5fc364.js", "fileName": "batman.js",
"map": SourceMap { "map": SourceMap {
"file": "batman-1a5fc364.js", "file": "batman.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;;;;", "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": [], "names": [],
"sources": [ "sources": [
@ -34,9 +34,9 @@ console.log(test());
}, },
{ {
"code": undefined, "code": undefined,
"fileName": "batman-1a5fc364.js.map", "fileName": "batman.js.map",
"map": undefined, "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;;;;"}", "source": "{"version":3,"file":"batman.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, "code": undefined,
@ -45,7 +45,7 @@ console.log(test());
"source": "<html><head> "source": "<html><head>
</head> </head>
<body> <body>
<script src="batman-1a5fc364.js" type="module"></script> <script src="batman.js" type="module"></script>
</body></html>", </body></html>",

View File

@ -7,12 +7,6 @@ import {debugPrintOutput, getCode} from "../util/index.ts";
import html from "../../src/index.ts"; import html from "../../src/index.ts";
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
};
import {fileURLToPath} from "node:url"; import {fileURLToPath} from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url)); const __dirname = dirname(fileURLToPath(import.meta.url));
process.chdir(join(__dirname, 'fixtures')); process.chdir(join(__dirname, 'fixtures'));
@ -29,7 +23,7 @@ test('live-reload', async () => {
}) })
] ]
}); });
const code = await getCode(bundle, output); const code = await getCode(bundle);
await bundle.close();// Make sure live-reload closes itself await bundle.close();// Make sure live-reload closes itself
debugPrintOutput('live-reload',code); debugPrintOutput('live-reload',code);
expect(code).toMatchSnapshot(); expect(code).toMatchSnapshot();

View File

@ -7,11 +7,11 @@ exports[`multi-entry 1`] = `
console.log(b()); console.log(b());
export { b }; export { b };
//# sourceMappingURL=batman-c7fa228c.js.map //# sourceMappingURL=batman.js.map
", ",
"fileName": "admin/batman-c7fa228c.js", "fileName": "admin/batman.js",
"map": SourceMap { "map": SourceMap {
"file": "batman-c7fa228c.js", "file": "batman.js",
"mappings": "AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;", "mappings": "AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;",
"names": [], "names": [],
"sources": [ "sources": [
@ -28,15 +28,15 @@ console.log(b());
}, },
{ {
"code": undefined, "code": undefined,
"fileName": "admin/batman-c7fa228c.js.map", "fileName": "admin/batman.js.map",
"map": undefined, "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;;;;"}", "source": "{"version":3,"file":"batman.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, "code": undefined,
"fileName": "admin/index.body.script0.js-15dfaff3.js.map", "fileName": "admin/index.body.script0.js.js.map",
"map": undefined, "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"}", "source": "{"version":3,"file":"index.body.script0.js.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, "code": undefined,
@ -46,16 +46,16 @@ console.log(b());
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
<script type="module">import { b as bootstrap } from '../app-01141b67.js'; <script type="module">import { b as bootstrap } from '../app.js';
function adminDeps(){ function adminDeps(){
return "robin!"; return "robin!";
} }
bootstrap(document.getElementById('root'), adminDeps()); bootstrap(document.getElementById('root'), adminDeps());
//# sourceMappingURL=index.body.script0.js-15dfaff3.js.map //# sourceMappingURL=index.body.script0.js.js.map
</script> </script>
<script src="batman-c7fa228c.js" type="module"></script> <script src="batman.js" type="module"></script>
</body></html>", </body></html>",
@ -69,11 +69,11 @@ bootstrap(document.getElementById('root'), adminDeps());
}; };
export { bootstrap as b }; export { bootstrap as b };
//# sourceMappingURL=app-01141b67.js.map //# sourceMappingURL=app.js.map
", ",
"fileName": "app-01141b67.js", "fileName": "app.js",
"map": SourceMap { "map": SourceMap {
"file": "app-01141b67.js", "file": "app.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;;;;", "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": [], "names": [],
"sources": [ "sources": [
@ -94,15 +94,15 @@ export { bootstrap as b };
}, },
{ {
"code": undefined, "code": undefined,
"fileName": "app-01141b67.js.map", "fileName": "app.js.map",
"map": undefined, "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;;;;"}", "source": "{"version":3,"file":"app.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, "code": undefined,
"fileName": "index.body.script.js-45303f0f.js.map", "fileName": "index.body.script.js.js.map",
"map": undefined, "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"}", "source": "{"version":3,"file":"index.body.script.js.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, "code": undefined,
@ -112,10 +112,10 @@ export { bootstrap as b };
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
<script type="module">import { b as bootstrap } from './app-01141b67.js'; <script type="module">import { b as bootstrap } from './app.js';
bootstrap(document.getElementById('root'), "<none>"); bootstrap(document.getElementById('root'), "<none>");
//# sourceMappingURL=index.body.script.js-45303f0f.js.map //# sourceMappingURL=index.body.script.js.js.map
</script> </script>

View File

@ -6,12 +6,6 @@ import {debugPrintOutput, getCode} from "../util/index.ts";
import html from "../../src/index.ts"; import html from "../../src/index.ts";
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
};
import {fileURLToPath} from "node:url"; import {fileURLToPath} from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url)); const __dirname = dirname(fileURLToPath(import.meta.url));
process.chdir(join(__dirname, 'fixtures')); process.chdir(join(__dirname, 'fixtures'));
@ -28,7 +22,7 @@ test('multi-entry', async () => {
}), }),
] ]
}); });
const code = await getCode(bundle, output); const code = await getCode(bundle);
debugPrintOutput('multi-entry',code); debugPrintOutput('multi-entry',code);
expect(code).toMatchSnapshot(); expect(code).toMatchSnapshot();
}); });

View File

@ -1,68 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`rewrite-url 1`] = ` exports[`rewrite-url 1`] = `undefined`;
[
{
"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>",
},
]
`;

View File

@ -7,11 +7,11 @@ exports[`handlebars 1`] = `
console.log(b()); console.log(b());
export { b }; export { b };
//# sourceMappingURL=batman-c7fa228c.js.map //# sourceMappingURL=batman.js.map
", ",
"fileName": "batman-c7fa228c.js", "fileName": "batman.js",
"map": SourceMap { "map": SourceMap {
"file": "batman-c7fa228c.js", "file": "batman.js",
"mappings": "AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;", "mappings": "AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;",
"names": [], "names": [],
"sources": [ "sources": [
@ -28,9 +28,9 @@ console.log(b());
}, },
{ {
"code": undefined, "code": undefined,
"fileName": "batman-c7fa228c.js.map", "fileName": "batman.js.map",
"map": undefined, "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;;;;"}", "source": "{"version":3,"file":"batman.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, "code": undefined,
@ -40,7 +40,7 @@ console.log(b());
<meta data-test="a"> <meta data-test="a">
</head> </head>
<body> <body>
<script src="batman-c7fa228c.js" type="module"></script> <script src="batman.js" type="module"></script>
</body></html>", </body></html>",

View File

@ -8,12 +8,6 @@ import {debugPrintOutput, getCode} from "../util/index.ts";
import html from "../../src/index.ts"; import html from "../../src/index.ts";
import handlebars from "handlebars"; import handlebars from "handlebars";
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
};
import {fileURLToPath} from "node:url"; import {fileURLToPath} from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url)); const __dirname = dirname(fileURLToPath(import.meta.url));
process.chdir(join(__dirname, 'fixtures')); process.chdir(join(__dirname, 'fixtures'));
@ -29,7 +23,7 @@ test('handlebars', async () => {
}) })
] ]
}); });
const code = await getCode(bundle, output); const code = await getCode(bundle);
debugPrintOutput('handlebars',code); debugPrintOutput('handlebars',code);
expect(code).toMatchSnapshot(); expect(code).toMatchSnapshot();
}); });

View File

@ -7,11 +7,11 @@ exports[`url-plugin copied-assets 1`] = `
console.log(b()); console.log(b());
export { b }; export { b };
//# sourceMappingURL=batman-c7fa228c.js.map //# sourceMappingURL=batman.js.map
", ",
"fileName": "batman-c7fa228c.js", "fileName": "batman.js",
"map": SourceMap { "map": SourceMap {
"file": "batman-c7fa228c.js", "file": "batman.js",
"mappings": "AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;", "mappings": "AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;",
"names": [], "names": [],
"sources": [ "sources": [
@ -28,9 +28,9 @@ console.log(b());
}, },
{ {
"code": undefined, "code": undefined,
"fileName": "batman-c7fa228c.js.map", "fileName": "batman.js.map",
"map": undefined, "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;;;;"}", "source": "{"version":3,"file":"batman.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, "code": undefined,
@ -40,7 +40,7 @@ console.log(b());
<link rel="icon" href="fb585fdb6db313c9.svg"> <link rel="icon" href="fb585fdb6db313c9.svg">
</head> </head>
<body> <body>
<script src="batman-c7fa228c.js" type="module"></script> <script src="batman.js" type="module"></script>
</body></html>", </body></html>",
@ -55,11 +55,11 @@ exports[`url-plugin inlined-assets 1`] = `
console.log(b()); console.log(b());
export { b }; export { b };
//# sourceMappingURL=batman-c7fa228c.js.map //# sourceMappingURL=batman.js.map
", ",
"fileName": "batman-c7fa228c.js", "fileName": "batman.js",
"map": SourceMap { "map": SourceMap {
"file": "batman-c7fa228c.js", "file": "batman.js",
"mappings": "AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;", "mappings": "AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;",
"names": [], "names": [],
"sources": [ "sources": [
@ -76,9 +76,9 @@ console.log(b());
}, },
{ {
"code": undefined, "code": undefined,
"fileName": "batman-c7fa228c.js.map", "fileName": "batman.js.map",
"map": undefined, "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;;;;"}", "source": "{"version":3,"file":"batman.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, "code": undefined,
@ -88,7 +88,7 @@ console.log(b());
<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"> <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> </head>
<body> <body>
<script src="batman-c7fa228c.js" type="module"></script> <script src="batman.js" type="module"></script>
</body></html>", </body></html>",

View File

@ -8,11 +8,6 @@ import {debugPrintOutput, getCode} from "../util/index.ts";
import html from "../../src/index.ts"; import html from "../../src/index.ts";
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
};
import {fileURLToPath} from "node:url"; import {fileURLToPath} from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url)); const __dirname = dirname(fileURLToPath(import.meta.url));
@ -38,7 +33,7 @@ describe("url-plugin", ()=>{
}), }),
], ],
}); });
const code = await getCode(bundle, output); const code = await getCode(bundle);
debugPrintOutput('copied-assets',code); debugPrintOutput('copied-assets',code);
expect(code).toMatchSnapshot(); expect(code).toMatchSnapshot();
}); });
@ -56,7 +51,7 @@ describe("url-plugin", ()=>{
}), }),
] ]
}); });
const code = await getCode(bundle, output); const code = await getCode(bundle);
debugPrintOutput('inlined-assets',code); debugPrintOutput('inlined-assets',code);
expect(code).toMatchSnapshot(); expect(code).toMatchSnapshot();
}); });

View File

@ -2,8 +2,8 @@ import {Plugin, InputPluginOption, RollupOptions, OutputOptions, RollupOutput} f
import {TestOptions as BrowserTestOptions, TestOutput as PuppeteerTestOutput} from "./puppeteer-run-test.js"; import {TestOptions as BrowserTestOptions, TestOutput as PuppeteerTestOutput} from "./puppeteer-run-test.js";
import { rollup } from "rollup"; import { rollup } from "rollup";
import serveTest, {LogCallback} from "./serve-test.ts"; import serveTest, {LogCallback} from "./serve-test.ts";
import type {ExecutionContext} from "ava";
import {getCode, TestOutput} from "./code-output.ts"; import {getCode, TestOutput} from "./code-output.ts";
import {defaultOutput} from "./default-output.ts";
export interface OutputFilterOptions { export interface OutputFilterOptions {
html?: boolean html?: boolean
@ -56,17 +56,11 @@ export async function runBrowserTest(
}); });
// TODO make configurable? // TODO make configurable?
const generated = await bundle.generate({
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
chunkFileNames: '[name].js',
entryFileNames: '[name].mjs',
assetFileNames: '[name].[extname]',
});
if(output){ if(output){
testOutput.code = await getCode(bundle, output); testOutput.code = await getCode(bundle);
}else{
const generated = await bundle.generate(defaultOutput);
} }
await bundle.close(); await bundle.close();

View File

@ -1,4 +1,5 @@
import type {RollupBuild, OutputOptions, OutputAsset, OutputChunk, SourceMap} from "rollup"; import type {RollupBuild, OutputOptions, OutputAsset, OutputChunk, SourceMap} from "rollup";
import {defaultOutput} from "./default-output.ts";
export interface TestOutput{ export interface TestOutput{
code: string, code: string,
@ -7,7 +8,7 @@ export interface TestOutput{
map: any map: any
} }
export const getCode = async (bundle: RollupBuild, outputOptions: OutputOptions): Promise<TestOutput[]> => { export const getCode = async (bundle: RollupBuild, outputOptions: OutputOptions = defaultOutput): Promise<TestOutput[]> => {
const { output } = await bundle.generate(outputOptions || { format: 'cjs', exports: 'auto' }); const { output } = await bundle.generate(outputOptions || { format: 'cjs', exports: 'auto' });
return output.sort((a,b)=> { return output.sort((a,b)=> {

View File

@ -0,0 +1,11 @@
import type {OutputOptions} from "rollup";
export const defaultOutput : OutputOptions = {
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].js',
assetFileNames: '[name].[extname]',
};

View File

@ -28,9 +28,6 @@ import type {
} from 'http' } from 'http'
import type { ServerOptions } from 'https' import type { ServerOptions } from 'https'
import test, {ExecutionContext} from "ava";
import {createReadStream} from "fs";
type TypeMap = { type TypeMap = {
[key: string]: string[]; [key: string]: string[];

View File

@ -8,18 +8,10 @@ import {writeFile} from "node:fs/promises";
import html from "../../src/index.ts"; import html from "../../src/index.ts";
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"; import {fileURLToPath} from "node:url";
import {pathToFileURL} from "url"; import {pathToFileURL} from "url";
import {defaultOutput} from "../util/default-output.ts";
const __dirname = dirname(fileURLToPath(import.meta.url)); const __dirname = dirname(fileURLToPath(import.meta.url));
process.chdir(join(__dirname, 'fixtures')); process.chdir(join(__dirname, 'fixtures'));
@ -35,9 +27,10 @@ test('watch', async () => {
const path = resolve(__dirname, 'fixtures/watched-file.js'); const path = resolve(__dirname, 'fixtures/watched-file.js');
await writeFile(path, origContent, {encoding: 'utf-8'}); await writeFile(path, origContent, {encoding: 'utf-8'});
const output = defaultOutput;
const watcher = rollup.watch({ const watcher = rollup.watch({
input: 'index.html', input: 'index.html',
output, output: output,
plugins: [ plugins: [
html({ html({
}), }),
@ -53,7 +46,7 @@ test('watch', async () => {
// Just wait on the watch mode to pick up on the changes // Just wait on the watch mode to pick up on the changes
}, },
async (bundle)=>{ async (bundle)=>{
const code = await getCode(bundle, output); const code = await getCode(bundle);
debugPrintOutput('watch',code); debugPrintOutput('watch',code);
// Reset the source file // Reset the source file