First private release. Check updated README.md for details
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
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());
|
||||
|
||||
7
test/basic/fixtures/index.html
Normal file
7
test/basic/fixtures/index.html
Normal file
@@ -0,0 +1,7 @@
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<script src="./batman.js" type="module"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1 +0,0 @@
|
||||
* { width: 100%; }
|
||||
@@ -1,2 +0,0 @@
|
||||
// eslint-disable-next-line
|
||||
import style from './joker.css';
|
||||
@@ -1,2 +0,0 @@
|
||||
// eslint-disable-next-line
|
||||
import * as batman from './batman.js';
|
||||
@@ -1,357 +1,58 @@
|
||||
# Snapshot report for `test/test.js`
|
||||
# Snapshot report for `test/basic/test.js`
|
||||
|
||||
The actual snapshot is saved in `test.js.snap`.
|
||||
|
||||
Generated by [AVA](https://avajs.dev).
|
||||
|
||||
## default options
|
||||
## simple
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
[
|
||||
{
|
||||
code: `(function (factory) {␊
|
||||
typeof define === 'function' && define.amd ? define(factory) :␊
|
||||
factory();␊
|
||||
})((function () { 'use strict';␊
|
||||
code: `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-9dbe0e1d.js.map␊
|
||||
`,
|
||||
fileName: 'batman.js',
|
||||
map: null,
|
||||
fileName: 'batman-9dbe0e1d.js',
|
||||
map: SourceMap {
|
||||
file: 'batman-9dbe0e1d.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-9dbe0e1d.js.map',
|
||||
map: undefined,
|
||||
source: '{"version":3,"file":"batman-9dbe0e1d.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: `␊
|
||||
<!doctype html>␊
|
||||
<html lang="en">␊
|
||||
<head>␊
|
||||
<meta charset="utf-8">␊
|
||||
<title>Rollup Bundle</title>␊
|
||||
source: `<html><head>␊
|
||||
</head>␊
|
||||
<body>␊
|
||||
<script src="batman-9dbe0e1d.js" type="module"></script>␊
|
||||
␊
|
||||
</head>␊
|
||||
<body>␊
|
||||
<script src="batman.js"></script>␊
|
||||
</body>␊
|
||||
</html>`,
|
||||
},
|
||||
]
|
||||
|
||||
## options
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
[
|
||||
{
|
||||
code: `(function (factory) {␊
|
||||
typeof define === 'function' && define.amd ? define(factory) :␊
|
||||
factory();␊
|
||||
})((function () { 'use strict';␊
|
||||
␊
|
||||
␊
|
||||
␊
|
||||
}));␊
|
||||
`,
|
||||
fileName: 'batman.js',
|
||||
map: null,
|
||||
source: undefined,
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'batman.html',
|
||||
map: undefined,
|
||||
source: `␊
|
||||
<!doctype html>␊
|
||||
<html lang="en">␊
|
||||
<head>␊
|
||||
<meta charset="utf-8">␊
|
||||
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width">␊
|
||||
<title>Batcave</title>␊
|
||||
␊
|
||||
</head>␊
|
||||
<body>␊
|
||||
<script src="batcave/batman.js"></script>␊
|
||||
</body>␊
|
||||
</html>`,
|
||||
},
|
||||
]
|
||||
|
||||
## iife
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
[
|
||||
{
|
||||
code: `(function () {␊
|
||||
'use strict';␊
|
||||
␊
|
||||
␊
|
||||
␊
|
||||
})();␊
|
||||
`,
|
||||
fileName: 'batman.js',
|
||||
map: null,
|
||||
source: undefined,
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'index.html',
|
||||
map: undefined,
|
||||
source: `␊
|
||||
<!doctype html>␊
|
||||
<html lang="en">␊
|
||||
<head>␊
|
||||
<meta charset="utf-8">␊
|
||||
<title>Rollup Bundle</title>␊
|
||||
␊
|
||||
</head>␊
|
||||
<body>␊
|
||||
<script src="batman.js"></script>␊
|
||||
</body>␊
|
||||
</html>`,
|
||||
},
|
||||
]
|
||||
|
||||
## esm
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
[
|
||||
{
|
||||
code: `␊
|
||||
`,
|
||||
fileName: 'batman.js',
|
||||
map: null,
|
||||
source: undefined,
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'index.html',
|
||||
map: undefined,
|
||||
source: `␊
|
||||
<!doctype html>␊
|
||||
<html lang="en">␊
|
||||
<head>␊
|
||||
<meta charset="utf-8">␊
|
||||
<title>Rollup Bundle</title>␊
|
||||
␊
|
||||
</head>␊
|
||||
<body>␊
|
||||
<script src="batman.js" type="module"></script>␊
|
||||
</body>␊
|
||||
</html>`,
|
||||
},
|
||||
]
|
||||
|
||||
## unsupported output format
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
[
|
||||
{
|
||||
code: `'use strict';␊
|
||||
␊
|
||||
`,
|
||||
fileName: 'batman.js',
|
||||
map: null,
|
||||
source: undefined,
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'index.html',
|
||||
map: undefined,
|
||||
source: `␊
|
||||
<!doctype html>␊
|
||||
<html lang="en">␊
|
||||
<head>␊
|
||||
<meta charset="utf-8">␊
|
||||
<title>Rollup Bundle</title>␊
|
||||
␊
|
||||
</head>␊
|
||||
<body>␊
|
||||
<script src="batman.js" type="module"></script>␊
|
||||
</body>␊
|
||||
</html>`,
|
||||
},
|
||||
]
|
||||
|
||||
> Snapshot 2
|
||||
|
||||
[
|
||||
{
|
||||
code: 'EMPTY_BUNDLE',
|
||||
message: 'Generated an empty chunk: "batman".',
|
||||
names: [
|
||||
'batman',
|
||||
],
|
||||
toString: Function {},
|
||||
},
|
||||
{
|
||||
code: 'PLUGIN_WARNING',
|
||||
message: 'plugin-html: The output format \'cjs\' is not directly supported. A custom `template` is probably required. Supported formats include: es, esm, iife, umd',
|
||||
plugin: 'html',
|
||||
toString: Function {},
|
||||
},
|
||||
]
|
||||
|
||||
## css
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
[
|
||||
{
|
||||
code: `(function (factory) {␊
|
||||
typeof define === 'function' && define.amd ? define(factory) :␊
|
||||
factory();␊
|
||||
})((function () { 'use strict';␊
|
||||
␊
|
||||
␊
|
||||
␊
|
||||
}));␊
|
||||
`,
|
||||
fileName: 'joker.js',
|
||||
map: null,
|
||||
source: undefined,
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'joker.css',
|
||||
map: undefined,
|
||||
source: Buffer @Uint8Array [
|
||||
2a207b20 77696474 683a2031 3030253b 207d0a
|
||||
],
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'index.html',
|
||||
map: undefined,
|
||||
source: `␊
|
||||
<!doctype html>␊
|
||||
<html lang="en">␊
|
||||
<head>␊
|
||||
<meta charset="utf-8">␊
|
||||
<title>Rollup Bundle</title>␊
|
||||
<link href="joker.css" rel="stylesheet">␊
|
||||
</head>␊
|
||||
<body>␊
|
||||
<script src="joker.js" type="module"></script>␊
|
||||
</body>␊
|
||||
</html>`,
|
||||
},
|
||||
]
|
||||
|
||||
## attributes
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
[
|
||||
{
|
||||
code: `(function (factory) {␊
|
||||
typeof define === 'function' && define.amd ? define(factory) :␊
|
||||
factory();␊
|
||||
})((function () { 'use strict';␊
|
||||
␊
|
||||
␊
|
||||
␊
|
||||
}));␊
|
||||
`,
|
||||
fileName: 'joker.js',
|
||||
map: null,
|
||||
source: undefined,
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'joker.css',
|
||||
map: undefined,
|
||||
source: Buffer @Uint8Array [
|
||||
2a207b20 77696474 683a2031 3030253b 207d0a
|
||||
],
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'index.html',
|
||||
map: undefined,
|
||||
source: `␊
|
||||
<!doctype html>␊
|
||||
<html batsignal="on" lang="bat">␊
|
||||
<head>␊
|
||||
<meta charset="utf-8">␊
|
||||
<title>Rollup Bundle</title>␊
|
||||
<link href="joker.css" rel="stylesheet" data-vilian="joker">␊
|
||||
</head>␊
|
||||
<body>␊
|
||||
<script src="joker.js" defer="true"></script>␊
|
||||
</body>␊
|
||||
</html>`,
|
||||
},
|
||||
]
|
||||
|
||||
## imports
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
[
|
||||
{
|
||||
code: `(function (factory) {␊
|
||||
typeof define === 'function' && define.amd ? define(factory) :␊
|
||||
factory();␊
|
||||
})((function () { 'use strict';␊
|
||||
␊
|
||||
␊
|
||||
␊
|
||||
}));␊
|
||||
`,
|
||||
fileName: 'robin.js',
|
||||
map: null,
|
||||
source: undefined,
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'index.html',
|
||||
map: undefined,
|
||||
source: `␊
|
||||
<!doctype html>␊
|
||||
<html lang="en">␊
|
||||
<head>␊
|
||||
<meta charset="utf-8">␊
|
||||
<title>Rollup Bundle</title>␊
|
||||
␊
|
||||
</head>␊
|
||||
<body>␊
|
||||
<script src="robin.js" type="module"></script>␊
|
||||
</body>␊
|
||||
</html>`,
|
||||
},
|
||||
]
|
||||
|
||||
## template
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
[
|
||||
{
|
||||
code: `(function (factory) {␊
|
||||
typeof define === 'function' && define.amd ? define(factory) :␊
|
||||
factory();␊
|
||||
})((function () { 'use strict';␊
|
||||
␊
|
||||
␊
|
||||
␊
|
||||
}));␊
|
||||
`,
|
||||
fileName: 'batman.js',
|
||||
map: null,
|
||||
source: undefined,
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'index.html',
|
||||
map: undefined,
|
||||
source: '<html><body><main></main></body></html>',
|
||||
␊
|
||||
</body></html>`,
|
||||
},
|
||||
]
|
||||
|
||||
Binary file not shown.
@@ -2,123 +2,36 @@ import {join, dirname} from "node:path";
|
||||
|
||||
import test from "ava";
|
||||
import { rollup } from "rollup";
|
||||
import css from "rollup-plugin-postcss";
|
||||
|
||||
import { getCode } from "../util/test.js";
|
||||
import {debugPrintOutput, getCode} from "../util/test.js";
|
||||
|
||||
import html from "../../src/index.ts";
|
||||
|
||||
// const read = (file = 'index.html') => readFileSync(join('output/', file), 'utf-8');
|
||||
|
||||
const output = { dir: 'output', format: 'umd' };
|
||||
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('default options', async (t) => {
|
||||
const bundle = await rollup({
|
||||
input: 'batman.js',
|
||||
plugins: [html()]
|
||||
});
|
||||
const code = await getCode(bundle, output, true);
|
||||
t.snapshot(code);
|
||||
});
|
||||
|
||||
test.serial('options', async (t) => {
|
||||
test.serial('simple', async (t) => {
|
||||
const bundle = await rollup({
|
||||
input: 'batman.js',
|
||||
input: 'index.html',
|
||||
plugins: [
|
||||
html({
|
||||
fileName: 'batman.html',
|
||||
publicPath: 'batcave/',
|
||||
title: 'Batcave',
|
||||
meta: [
|
||||
{ charset: 'utf-8' },
|
||||
{ name: 'viewport', content: 'minimum-scale=1, initial-scale=1, width=device-width' }
|
||||
]
|
||||
})
|
||||
}),
|
||||
]
|
||||
});
|
||||
const code = await getCode(bundle, output, true);
|
||||
debugPrintOutput('simple',code);
|
||||
t.snapshot(code);
|
||||
});
|
||||
|
||||
test.serial('iife', async (t) => {
|
||||
const bundle = await rollup({
|
||||
input: 'batman.js',
|
||||
plugins: [html()]
|
||||
});
|
||||
const code = await getCode(bundle, { dir: 'output', format: 'iife' }, true);
|
||||
t.snapshot(code);
|
||||
});
|
||||
|
||||
test.serial('esm', async (t) => {
|
||||
const bundle = await rollup({
|
||||
input: 'batman.js',
|
||||
plugins: [html()]
|
||||
});
|
||||
const code = await getCode(bundle, { dir: 'output', format: 'es' }, true);
|
||||
t.snapshot(code);
|
||||
});
|
||||
|
||||
test.serial('unsupported output format', async (t) => {
|
||||
const warnings = [];
|
||||
const bundle = await rollup({
|
||||
input: 'batman.js',
|
||||
onwarn: (warning) => warnings.push(warning),
|
||||
plugins: [html()]
|
||||
});
|
||||
const code = await getCode(bundle, { dir: 'output', format: 'cjs' }, true);
|
||||
t.snapshot(code);
|
||||
t.snapshot(warnings);
|
||||
});
|
||||
|
||||
test.serial('css', async (t) => {
|
||||
const bundle = await rollup({
|
||||
input: 'joker.js',
|
||||
plugins: [css({ extract: true }), html()]
|
||||
});
|
||||
const code = await getCode(bundle, output, true);
|
||||
t.snapshot(code);
|
||||
});
|
||||
|
||||
test.serial('attributes', async (t) => {
|
||||
const bundle = await rollup({
|
||||
input: 'joker.js',
|
||||
plugins: [
|
||||
css({ extract: true }),
|
||||
html({
|
||||
attributes: {
|
||||
html: { batsignal: 'on', lang: 'bat' },
|
||||
link: { 'data-vilian': 'joker' },
|
||||
script: { defer: true }
|
||||
}
|
||||
})
|
||||
]
|
||||
});
|
||||
const code = await getCode(bundle, output, true);
|
||||
t.snapshot(code);
|
||||
});
|
||||
|
||||
test.serial('imports', async (t) => {
|
||||
const bundle = await rollup({
|
||||
input: 'robin.js',
|
||||
plugins: [html()]
|
||||
});
|
||||
const code = await getCode(bundle, output, true);
|
||||
t.snapshot(code);
|
||||
});
|
||||
|
||||
test.serial('template', async (t) => {
|
||||
const bundle = await rollup({
|
||||
input: 'batman.js',
|
||||
plugins: [
|
||||
html({
|
||||
transform: () => '<html><body><main></main></body></html>'
|
||||
})
|
||||
]
|
||||
});
|
||||
const code = await getCode(bundle, output, true);
|
||||
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