WIP: Basic working version. Will import .html files and resolve its dependencies. But it will generate invalid html when sourcemaps are enabled, assets like <link..> do not yet work...

This commit is contained in:
2023-04-27 21:49:13 +02:00
parent 240d5cfe9a
commit 831e607591
8 changed files with 105 additions and 70 deletions

View File

@@ -1,6 +1,8 @@
<html>
<meta data-test="{{a}}"/>
<body>
<script src="./batman.js" type="module"></script>
</body>
<head>
<meta data-test="{{a}}"/>
</head>
<body>
<script src="./batman.js" type="module"></script>
</body>
</html>

View File

@@ -10,29 +10,65 @@ Generated by [AVA](https://avajs.dev).
[
{
code: `(function (factory) {
typeof define === 'function' && define.amd ? define(factory) :
factory();
})((function () { 'use strict';
=-u
code: `<html><head>
<meta data-test="a">
</head>
<body>
<script src="batman-f8ac73ff.js" type="module"></script>
}));
</body></html>
//# sourceMappingURL=index.html.map
`,
fileName: 'batman.js',
map: null,
fileName: 'index.html',
map: SourceMap {
file: 'index.html',
mappings: '',
names: [],
sources: [],
sourcesContent: [],
version: 3,
},
source: undefined,
},
{
code: `const notSoIifi = ()=>{␊
return \`I'm "annoying" ${"in case we need to test \\\`string\\\` escaping.''"}\`;␊
};␊
console.log(notSoIifi());␊
export { notSoIifi };␊
//# sourceMappingURL=batman-f8ac73ff.js.map␊
`,
fileName: 'batman-f8ac73ff.js',
map: SourceMap {
file: 'batman-f8ac73ff.js',
mappings: 'AAAY,MAAC,SAAS,GAAG,IAAI;AAC7B,IAAI,OAAO,CAAC,eAAe,EAAE,gDAAgD,CAAC,CAAC,CAAC;AAChF,EAAC;AACD,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;;;;',
names: [],
sources: [
'../batman.js',
],
sourcesContent: [
`export const notSoIifi = ()=>{␊
return \`I'm "annoying" ${"in case we need to test \\\`string\\\` escaping.''"}\`;␊
}␊
console.log(notSoIifi());␊
`,
],
version: 3,
},
source: undefined,
},
{
code: undefined,
fileName: 'index.html',
fileName: 'batman-f8ac73ff.js.map',
map: undefined,
source: `<html>␊
<meta data-test="a"/>␊
<body>␊
<script src="./batman.js" type="module"></script>␊
</body>␊
</html>␊
`,
source: '{"version":3,"file":"batman-f8ac73ff.js","sources":["../batman.js"],"sourcesContent":["export const notSoIifi = ()=>{\\n return `I\'m \\"annoying\\" ${\\"in case we need to test \\\\`string\\\\` escaping.\'\'\\"}`;\\n}\\nconsole.log(notSoIifi());\\n"],"names":[],"mappings":"AAAY,MAAC,SAAS,GAAG,IAAI;AAC7B,IAAI,OAAO,CAAC,eAAe,EAAE,gDAAgD,CAAC,CAAC,CAAC;AAChF,EAAC;AACD,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;;;;"}',
},
{
code: undefined,
fileName: 'index.html.map',
map: undefined,
source: '{"version":3,"file":"index.html","sources":[],"sourcesContent":[],"names":[],"mappings":""}',
},
]

Binary file not shown.

View File

@@ -8,7 +8,11 @@ import { getCode } from "../util/test.js";
import html from "../../src/index.ts";
import handlebars from "handlebars";
const output = { dir: 'output', format: 'es' };
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 {readFile} from "node:fs/promises";
import {fileURLToPath} from "node:url";