Supporting multri entry
This commit is contained in:
12
test/multi-entry/fixtures/admin/index.html
Normal file
12
test/multi-entry/fixtures/admin/index.html
Normal file
@@ -0,0 +1,12 @@
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module">
|
||||
import {bootstrap} from "../app/app.js"
|
||||
import {adminDeps} from "../app/admin-deps.js";
|
||||
bootstrap(document.getElementById('root'), adminDeps());
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
3
test/multi-entry/fixtures/app/admin-deps.js
Normal file
3
test/multi-entry/fixtures/app/admin-deps.js
Normal file
@@ -0,0 +1,3 @@
|
||||
export function adminDeps(){
|
||||
return "robin!";
|
||||
}
|
||||
6
test/multi-entry/fixtures/app/app.js
Normal file
6
test/multi-entry/fixtures/app/app.js
Normal file
@@ -0,0 +1,6 @@
|
||||
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>
|
||||
`;
|
||||
}
|
||||
11
test/multi-entry/fixtures/index.html
Normal file
11
test/multi-entry/fixtures/index.html
Normal file
@@ -0,0 +1,11 @@
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module">
|
||||
import {bootstrap} from "./app/app.js"
|
||||
bootstrap(document.getElementById('root'), "<none>");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
100
test/multi-entry/snapshots/test.js.md
Normal file
100
test/multi-entry/snapshots/test.js.md
Normal file
@@ -0,0 +1,100 @@
|
||||
# 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 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: 'index.html.body.script.js-45303f0f.js.map',
|
||||
map: undefined,
|
||||
source: '{"version":3,"file":"index.html.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: 'admin/index.html.body.script.js-15dfaff3.js.map',
|
||||
map: undefined,
|
||||
source: '{"version":3,"file":"index.html.body.script.js-15dfaff3.js","sources":["../../app/admin-deps.js","../../admin/index.html.body.script.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: '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.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.html.body.script.js-45303f0f.js.map␊
|
||||
</script>␊
|
||||
␊
|
||||
␊
|
||||
</body></html>`,
|
||||
},
|
||||
{
|
||||
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.html.body.script.js-15dfaff3.js.map␊
|
||||
</script>␊
|
||||
␊
|
||||
␊
|
||||
</body></html>`,
|
||||
},
|
||||
]
|
||||
BIN
test/multi-entry/snapshots/test.js.snap
Normal file
BIN
test/multi-entry/snapshots/test.js.snap
Normal file
Binary file not shown.
40
test/multi-entry/test.js
Normal file
40
test/multi-entry/test.js
Normal file
@@ -0,0 +1,40 @@
|
||||
import {join, dirname} from "node:path";
|
||||
|
||||
import test from "ava";
|
||||
import { rollup } from "rollup";
|
||||
import {debugPrintOutput, getCode} from "../util/test.js";
|
||||
|
||||
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";
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
process.chdir(join(__dirname, 'fixtures'));
|
||||
|
||||
|
||||
test.serial('multi-entry', async (t) => {
|
||||
const bundle = await rollup({
|
||||
input: {
|
||||
['index']: 'index.html',
|
||||
['admin/index']: 'admin/index.html'
|
||||
},
|
||||
plugins: [
|
||||
html({
|
||||
}),
|
||||
]
|
||||
});
|
||||
const code = await getCode(bundle, output, true);
|
||||
debugPrintOutput('multi-entry',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
|
||||
// ...
|
||||
Reference in New Issue
Block a user