@web/rollup-plugin-html 2.0.1 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/utils.js +2 -2
- package/dist/assets/utils.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/input/addRollupInput.d.ts +1 -1
- package/dist/input/addRollupInput.d.ts.map +1 -1
- package/dist/input/addRollupInput.js +2 -2
- package/dist/input/addRollupInput.js.map +1 -1
- package/dist/input/extract/extractAssets.d.ts +1 -1
- package/dist/input/extract/extractAssets.d.ts.map +1 -1
- package/dist/input/extract/extractAssets.js +5 -5
- package/dist/input/extract/extractAssets.js.map +1 -1
- package/dist/input/extract/extractModules.d.ts +1 -1
- package/dist/input/extract/extractModules.d.ts.map +1 -1
- package/dist/input/extract/extractModules.js +2 -2
- package/dist/input/extract/extractModules.js.map +1 -1
- package/dist/input/extract/extractModulesAndAssets.d.ts +3 -3
- package/dist/input/extract/extractModulesAndAssets.js +4 -4
- package/dist/input/extract/extractModulesAndAssets.js.map +1 -1
- package/dist/input/getInputData.d.ts +2 -2
- package/dist/input/getInputData.d.ts.map +1 -1
- package/dist/input/getInputData.js +9 -9
- package/dist/input/getInputData.js.map +1 -1
- package/dist/input/normalizeInputOptions.d.ts +1 -1
- package/dist/input/normalizeInputOptions.d.ts.map +1 -1
- package/dist/input/normalizeInputOptions.js +4 -4
- package/dist/input/normalizeInputOptions.js.map +1 -1
- package/dist/output/createHTMLOutput.d.ts +3 -3
- package/dist/output/createHTMLOutput.d.ts.map +1 -1
- package/dist/output/createHTMLOutput.js +6 -6
- package/dist/output/createHTMLOutput.js.map +1 -1
- package/dist/output/getEntrypointBundles.js +6 -6
- package/dist/output/getEntrypointBundles.js.map +1 -1
- package/dist/output/getOutputHTML.d.ts +1 -1
- package/dist/output/getOutputHTML.d.ts.map +1 -1
- package/dist/output/getOutputHTML.js +10 -10
- package/dist/output/getOutputHTML.js.map +1 -1
- package/dist/output/injectBundles.d.ts +1 -1
- package/dist/output/injectBundles.d.ts.map +1 -1
- package/dist/output/injectBundles.js +2 -2
- package/dist/output/injectBundles.js.map +1 -1
- package/dist/output/injectedUpdatedAssetPaths.d.ts +2 -2
- package/dist/output/injectedUpdatedAssetPaths.d.ts.map +1 -1
- package/dist/output/injectedUpdatedAssetPaths.js +10 -10
- package/dist/output/injectedUpdatedAssetPaths.js.map +1 -1
- package/dist/rollupPluginHTML.d.ts +2 -2
- package/dist/rollupPluginHTML.d.ts.map +1 -1
- package/dist/rollupPluginHTML.js +19 -19
- package/dist/rollupPluginHTML.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/assets/utils.ts +1 -1
- package/src/index.ts +2 -2
- package/src/input/addRollupInput.ts +2 -2
- package/src/input/extract/extractAssets.ts +2 -2
- package/src/input/extract/extractModules.ts +2 -2
- package/src/input/extract/extractModulesAndAssets.ts +2 -2
- package/src/input/getInputData.ts +8 -8
- package/src/input/normalizeInputOptions.ts +2 -2
- package/src/output/createHTMLOutput.ts +6 -6
- package/src/output/getEntrypointBundles.ts +2 -2
- package/src/output/getOutputHTML.ts +6 -6
- package/src/output/injectBundles.ts +2 -2
- package/src/output/injectedUpdatedAssetPaths.ts +5 -5
- package/src/rollupPluginHTML.ts +7 -7
- package/src/utils.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Document, Attribute } from 'parse5';
|
|
2
|
-
import { EntrypointBundle } from '../RollupPluginHTMLOptions';
|
|
2
|
+
import { EntrypointBundle } from '../RollupPluginHTMLOptions.js';
|
|
3
3
|
export declare function createLoadScript(src: string, format: string, attributes?: Attribute[]): import("parse5").Element;
|
|
4
4
|
export declare function injectBundles(document: Document, entrypointBundles: Record<string, EntrypointBundle>): void;
|
|
5
5
|
//# sourceMappingURL=injectBundles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectBundles.d.ts","sourceRoot":"","sources":["../../src/output/injectBundles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAG7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"injectBundles.d.ts","sourceRoot":"","sources":["../../src/output/injectBundles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAG7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,SAAS,EAAE,4BAgBrF;AAED,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,QAAQ,EAClB,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,QAiBpD"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.injectBundles = exports.createLoadScript = void 0;
|
|
4
4
|
const parse5_utils_1 = require("@web/parse5-utils");
|
|
5
|
-
const
|
|
5
|
+
const utils_js_1 = require("../utils.js");
|
|
6
6
|
function createLoadScript(src, format, attributes) {
|
|
7
7
|
const attributesObject = {};
|
|
8
8
|
if (attributes) {
|
|
@@ -26,7 +26,7 @@ function injectBundles(document, entrypointBundles) {
|
|
|
26
26
|
}
|
|
27
27
|
for (const { options, entrypoints } of Object.values(entrypointBundles)) {
|
|
28
28
|
if (!options.format)
|
|
29
|
-
throw (0,
|
|
29
|
+
throw (0, utils_js_1.createError)('Missing output format.');
|
|
30
30
|
for (const entrypoint of entrypoints) {
|
|
31
31
|
(0, parse5_utils_1.appendChild)(body, createLoadScript(entrypoint.importPath, options.format, entrypoint.attributes));
|
|
32
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectBundles.js","sourceRoot":"","sources":["../../src/output/injectBundles.ts"],"names":[],"mappings":";;;AACA,oDAAuF;AAGvF,
|
|
1
|
+
{"version":3,"file":"injectBundles.js","sourceRoot":"","sources":["../../src/output/injectBundles.ts"],"names":[],"mappings":";;;AACA,oDAAuF;AAGvF,0CAA0C;AAE1C,SAAgB,gBAAgB,CAAC,GAAW,EAAE,MAAc,EAAE,UAAwB;IACpF,MAAM,gBAAgB,GAA2B,EAAE,CAAC;IACpD,IAAI,UAAU,EAAE;QACd,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE;YAClC,gBAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC;SACpD;KACF;IACD,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QAC5C,OAAO,IAAA,2BAAY,kBAAG,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAK,gBAAgB,EAAG,CAAC;KACnE;IAED,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QAC3C,OAAO,IAAA,2BAAY,EAAC,EAAE,EAAE,iBAAiB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;KACnE;IAED,OAAO,IAAA,2BAAY,EAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;AAC1C,CAAC;AAhBD,4CAgBC;AAED,SAAgB,aAAa,CAC3B,QAAkB,EAClB,iBAAmD;IAEnD,MAAM,IAAI,GAAG,IAAA,0BAAW,EAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,IAAA,yBAAU,EAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC;IAClE,IAAI,CAAC,IAAI,EAAE;QACT,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;KACnD;IAED,KAAK,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAE;QACvE,IAAI,CAAC,OAAO,CAAC,MAAM;YAAE,MAAM,IAAA,sBAAW,EAAC,wBAAwB,CAAC,CAAC;QAEjE,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;YACpC,IAAA,0BAAW,EACT,IAAI,EACJ,gBAAgB,CAAC,UAAU,CAAC,UAAU,EAAE,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,UAAU,CAAC,CAC/E,CAAC;SACH;KACF;AACH,CAAC;AAnBD,sCAmBC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Document } from 'parse5';
|
|
2
|
-
import { InputData } from '../input/InputData';
|
|
3
|
-
import { EmittedAssets } from './emitAssets';
|
|
2
|
+
import { InputData } from '../input/InputData.js';
|
|
3
|
+
import { EmittedAssets } from './emitAssets.js';
|
|
4
4
|
export interface InjectUpdatedAssetPathsArgs {
|
|
5
5
|
document: Document;
|
|
6
6
|
input: InputData;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectedUpdatedAssetPaths.d.ts","sourceRoot":"","sources":["../../src/output/injectedUpdatedAssetPaths.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAUlC,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"injectedUpdatedAssetPaths.d.ts","sourceRoot":"","sources":["../../src/output/injectedUpdatedAssetPaths.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAUlC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,SAAS,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,aAAa,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAaD,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,2BAA2B,QAmD1E"}
|
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.injectedUpdatedAssetPaths = void 0;
|
|
7
7
|
const parse5_utils_1 = require("@web/parse5-utils");
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
9
|
+
const utils_js_1 = require("../assets/utils.js");
|
|
10
|
+
const utils_js_2 = require("../utils.js");
|
|
11
|
+
const utils_js_3 = require("./utils.js");
|
|
12
12
|
function getSrcSetUrlWidthPairs(srcset) {
|
|
13
13
|
if (!srcset) {
|
|
14
14
|
return [];
|
|
@@ -21,24 +21,24 @@ function getSrcSetUrlWidthPairs(srcset) {
|
|
|
21
21
|
}
|
|
22
22
|
function injectedUpdatedAssetPaths(args) {
|
|
23
23
|
const { document, input, outputDir, rootDir, emittedAssets, publicPath = './', absolutePathPrefix, } = args;
|
|
24
|
-
const assetNodes = (0,
|
|
24
|
+
const assetNodes = (0, utils_js_1.findAssets)(document);
|
|
25
25
|
for (const node of assetNodes) {
|
|
26
|
-
const sourcePaths = (0,
|
|
26
|
+
const sourcePaths = (0, utils_js_1.getSourcePaths)(node);
|
|
27
27
|
for (const sourcePath of sourcePaths) {
|
|
28
28
|
const htmlFilePath = input.filePath ? input.filePath : path_1.default.join(rootDir, input.name);
|
|
29
29
|
const htmlDir = path_1.default.dirname(htmlFilePath);
|
|
30
|
-
const filePath = (0,
|
|
31
|
-
const assetPaths = (0,
|
|
30
|
+
const filePath = (0, utils_js_1.resolveAssetFilePath)(sourcePath, htmlDir, rootDir, absolutePathPrefix);
|
|
31
|
+
const assetPaths = (0, utils_js_1.isHashedAsset)(node) ? emittedAssets.hashed : emittedAssets.static;
|
|
32
32
|
const relativeOutputPath = assetPaths.get(filePath);
|
|
33
33
|
if (!relativeOutputPath) {
|
|
34
|
-
throw (0,
|
|
34
|
+
throw (0, utils_js_2.createError)(`Something went wrong while bundling HTML file ${input.name}. Could not find ${filePath} in emitted rollup assets.`);
|
|
35
35
|
}
|
|
36
36
|
const htmlOutputFilePath = path_1.default.join(outputDir, input.name);
|
|
37
37
|
const htmlOutputDir = path_1.default.dirname(htmlOutputFilePath);
|
|
38
38
|
const absoluteOutputPath = path_1.default.join(outputDir, relativeOutputPath);
|
|
39
39
|
const relativePathToHtmlFile = path_1.default.relative(htmlOutputDir, absoluteOutputPath);
|
|
40
|
-
const browserPath = path_1.default.posix.join(publicPath, (0,
|
|
41
|
-
const key = (0,
|
|
40
|
+
const browserPath = path_1.default.posix.join(publicPath, (0, utils_js_3.toBrowserPath)(relativePathToHtmlFile));
|
|
41
|
+
const key = (0, utils_js_1.getSourceAttribute)(node);
|
|
42
42
|
let newAttributeValue = browserPath;
|
|
43
43
|
if (key === 'srcset') {
|
|
44
44
|
const srcset = (0, parse5_utils_1.getAttribute)(node, key);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectedUpdatedAssetPaths.js","sourceRoot":"","sources":["../../src/output/injectedUpdatedAssetPaths.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA+D;AAE/D,gDAAwB;AAExB,
|
|
1
|
+
{"version":3,"file":"injectedUpdatedAssetPaths.js","sourceRoot":"","sources":["../../src/output/injectedUpdatedAssetPaths.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA+D;AAE/D,gDAAwB;AAExB,iDAM4B;AAE5B,0CAA0C;AAE1C,yCAA2C;AAY3C,SAAS,sBAAsB,CAAC,MAAc;IAC5C,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,EAA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AAG,aAAa,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;iBAC1F;aACF;YAED,IAAA,2BAAY,EAAC,IAAI,EAAE,GAAG,EAAE,iBAAiB,CAAC,CAAC;SAC5C;KACF;AACH,CAAC;AAnDD,8DAmDC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Plugin } from 'rollup';
|
|
2
|
-
import { InputData } from './input/InputData';
|
|
3
|
-
import { RollupPluginHTMLOptions, TransformHtmlFunction } from './RollupPluginHTMLOptions';
|
|
2
|
+
import { InputData } from './input/InputData.js';
|
|
3
|
+
import { RollupPluginHTMLOptions, TransformHtmlFunction } from './RollupPluginHTMLOptions.js';
|
|
4
4
|
export interface RollupPluginHtml extends Plugin {
|
|
5
5
|
api: {
|
|
6
6
|
getInputs(): InputData[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollupPluginHTML.d.ts","sourceRoot":"","sources":["../src/rollupPluginHTML.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKhC,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"rollupPluginHTML.d.ts","sourceRoot":"","sources":["../src/rollupPluginHTML.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKhC,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,OAAO,EAEL,uBAAuB,EAEvB,qBAAqB,EACtB,MAAM,8BAA8B,CAAC;AAItC,MAAM,WAAW,gBAAiB,SAAQ,MAAM;IAC9C,GAAG,EAAE;QACH,SAAS,IAAI,SAAS,EAAE,CAAC;QACzB,kBAAkB,CAAC,qBAAqB,EAAE,qBAAqB,GAAG,IAAI,CAAC;QACvE,oBAAoB,IAAI,IAAI,CAAC;QAC7B,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;KACjC,CAAC;CACH;AAED,wBAAgB,gBAAgB,CAAC,aAAa,GAAE,uBAA4B,GAAG,gBAAgB,CAsM9F"}
|
package/dist/rollupPluginHTML.js
CHANGED
|
@@ -5,11 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.rollupPluginHTML = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
8
|
+
const addRollupInput_js_1 = require("./input/addRollupInput.js");
|
|
9
|
+
const getInputData_js_1 = require("./input/getInputData.js");
|
|
10
|
+
const createHTMLOutput_js_1 = require("./output/createHTMLOutput.js");
|
|
11
|
+
const utils_js_1 = require("./utils.js");
|
|
12
|
+
const emitAssets_js_1 = require("./output/emitAssets.js");
|
|
13
13
|
function rollupPluginHTML(pluginOptions = {}) {
|
|
14
14
|
const multiOutputNames = [];
|
|
15
15
|
let inputs = [];
|
|
@@ -29,7 +29,7 @@ function rollupPluginHTML(pluginOptions = {}) {
|
|
|
29
29
|
name: '@web/rollup-plugin-html',
|
|
30
30
|
options(inputOptions) {
|
|
31
31
|
reset();
|
|
32
|
-
inputs = (0,
|
|
32
|
+
inputs = (0, getInputData_js_1.getInputData)(pluginOptions, inputOptions.input);
|
|
33
33
|
const moduleImports = [];
|
|
34
34
|
for (const input of inputs) {
|
|
35
35
|
moduleImports.push(...input.moduleImports);
|
|
@@ -37,7 +37,7 @@ function rollupPluginHTML(pluginOptions = {}) {
|
|
|
37
37
|
if (moduleImports.length === 0) {
|
|
38
38
|
// if there are only pages with pure HTML we need to make sure there is at
|
|
39
39
|
// least some input for rollup
|
|
40
|
-
moduleImports.push(
|
|
40
|
+
moduleImports.push(utils_js_1.NOOP_IMPORT);
|
|
41
41
|
}
|
|
42
42
|
if (pluginOptions.serviceWorkerPath) {
|
|
43
43
|
serviceWorkerPath = pluginOptions.serviceWorkerPath;
|
|
@@ -57,7 +57,7 @@ function rollupPluginHTML(pluginOptions = {}) {
|
|
|
57
57
|
}
|
|
58
58
|
else {
|
|
59
59
|
// we need to add modules to existing rollup input
|
|
60
|
-
return (0,
|
|
60
|
+
return (0, addRollupInput_js_1.addRollupInput)(inputOptions, moduleImports);
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
63
|
/** Watch input files when running in watch mode */
|
|
@@ -74,8 +74,8 @@ function rollupPluginHTML(pluginOptions = {}) {
|
|
|
74
74
|
},
|
|
75
75
|
/** Notifies rollup that we will be handling these modules */
|
|
76
76
|
resolveId(id) {
|
|
77
|
-
if (id ===
|
|
78
|
-
return
|
|
77
|
+
if (id === utils_js_1.NOOP_IMPORT.importPath) {
|
|
78
|
+
return utils_js_1.NOOP_IMPORT.importPath;
|
|
79
79
|
}
|
|
80
80
|
for (const input of inputs) {
|
|
81
81
|
if (input.inlineModules.find(mod => mod.importPath === id)) {
|
|
@@ -85,7 +85,7 @@ function rollupPluginHTML(pluginOptions = {}) {
|
|
|
85
85
|
},
|
|
86
86
|
/** Provide code for modules we are handling */
|
|
87
87
|
load(id) {
|
|
88
|
-
if (id ===
|
|
88
|
+
if (id === utils_js_1.NOOP_IMPORT.importPath) {
|
|
89
89
|
return 'export default "noop"';
|
|
90
90
|
}
|
|
91
91
|
for (const input of inputs) {
|
|
@@ -106,11 +106,11 @@ function rollupPluginHTML(pluginOptions = {}) {
|
|
|
106
106
|
return;
|
|
107
107
|
}
|
|
108
108
|
if (!options.dir) {
|
|
109
|
-
throw (0,
|
|
109
|
+
throw (0, utils_js_1.createError)('Rollup output options must have a dir option set to emit an HTML file.');
|
|
110
110
|
}
|
|
111
111
|
generatedBundles.push({ name: 'default', options, bundle });
|
|
112
|
-
const emittedAssets = await
|
|
113
|
-
const outputs = await (0,
|
|
112
|
+
const emittedAssets = await emitAssets_js_1.emitAssets.call(this, inputs, pluginOptions);
|
|
113
|
+
const outputs = await (0, createHTMLOutput_js_1.createHTMLOutput)({
|
|
114
114
|
outputDir: path_1.default.resolve(options.dir),
|
|
115
115
|
inputs,
|
|
116
116
|
emittedAssets,
|
|
@@ -139,24 +139,24 @@ function rollupPluginHTML(pluginOptions = {}) {
|
|
|
139
139
|
},
|
|
140
140
|
addOutput(name) {
|
|
141
141
|
if (!name || multiOutputNames.includes(name)) {
|
|
142
|
-
throw (0,
|
|
142
|
+
throw (0, utils_js_1.createError)('Each output must have a unique name');
|
|
143
143
|
}
|
|
144
144
|
multiOutputNames.push(name);
|
|
145
145
|
return {
|
|
146
146
|
name: `@web/rollup-plugin-html-multi-output-${multiOutputNames.length}`,
|
|
147
147
|
async generateBundle(options, bundle) {
|
|
148
148
|
if (!options.dir) {
|
|
149
|
-
throw (0,
|
|
149
|
+
throw (0, utils_js_1.createError)(`Output ${name} must have a dir option set.`);
|
|
150
150
|
}
|
|
151
151
|
generatedBundles.push({ name, options, bundle });
|
|
152
152
|
if (generatedBundles.length === multiOutputNames.length) {
|
|
153
153
|
// this is the last build, emit the HTML files
|
|
154
154
|
const outputDirs = new Set(generatedBundles.map(b => b.options.dir));
|
|
155
155
|
if (outputDirs.size !== 1) {
|
|
156
|
-
throw (0,
|
|
156
|
+
throw (0, utils_js_1.createError)('Unable to emit HTML output. Multiple rollup build outputs have a different output directory set.');
|
|
157
157
|
}
|
|
158
|
-
const emittedAssets = await
|
|
159
|
-
const outputs = await (0,
|
|
158
|
+
const emittedAssets = await emitAssets_js_1.emitAssets.call(this, inputs, pluginOptions);
|
|
159
|
+
const outputs = await (0, createHTMLOutput_js_1.createHTMLOutput)({
|
|
160
160
|
outputDir: path_1.default.resolve(options.dir),
|
|
161
161
|
inputs,
|
|
162
162
|
emittedAssets,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollupPluginHTML.js","sourceRoot":"","sources":["../src/rollupPluginHTML.ts"],"names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,GAAG,MAAM,IAAA,sCAAgB,EAAC;gCACrC,SAAS,EAAE,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;gCACpC,MAAM;gCACN,aAAa;gCACb,gBAAgB;gCAChB,wBAAwB;gCACxB,aAAa;gCACb,qBAAqB;gCACrB,iBAAiB;gCACjB,mBAAmB;gCACnB,kBAAkB;gCAClB,sBAAsB;6BACvB,CAAC,CAAC;4BAEH,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;gCAC5B,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;6BACvB;yBACF;oBACH,CAAC;iBACQ,CAAC;YACd,CAAC;SACF;KACF,CAAC;AACJ,CAAC;AAtMD,4CAsMC"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ScriptModuleTag } from './RollupPluginHTMLOptions';
|
|
1
|
+
import { ScriptModuleTag } from './RollupPluginHTMLOptions.js';
|
|
2
2
|
export declare const NOOP_IMPORT: ScriptModuleTag;
|
|
3
3
|
export declare function createError(msg: string): Error;
|
|
4
4
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAI/D,eAAO,MAAM,WAAW,EAAE,eAAgE,CAAC;AAE3F,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,SAEtC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@web/rollup-plugin-html",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"engines": {
|
|
25
|
-
"node": ">=
|
|
25
|
+
"node": ">=18.0.0"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"demo:mpa": "rm -rf demo/dist && rollup -c demo/mpa/rollup.config.js --watch & npm run serve-demo",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"html"
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@web/parse5-utils": "^2.
|
|
48
|
-
"glob": "^
|
|
47
|
+
"@web/parse5-utils": "^2.1.0",
|
|
48
|
+
"glob": "^10.0.0",
|
|
49
49
|
"html-minifier-terser": "^7.1.0",
|
|
50
50
|
"parse5": "^6.0.1"
|
|
51
51
|
},
|
package/src/assets/utils.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Document, Element } from 'parse5';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { findElements, getTagName, getAttribute } from '@web/parse5-utils';
|
|
4
|
-
import { createError } from '../utils';
|
|
4
|
+
import { createError } from '../utils.js';
|
|
5
5
|
import { serialize } from 'v8';
|
|
6
6
|
|
|
7
7
|
const hashedLinkRels = ['stylesheet'];
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { rollupPluginHTML, RollupPluginHtml } from './rollupPluginHTML';
|
|
1
|
+
import { rollupPluginHTML, RollupPluginHtml } from './rollupPluginHTML.js';
|
|
2
2
|
|
|
3
3
|
export {
|
|
4
4
|
InputHTMLOptions,
|
|
@@ -8,7 +8,7 @@ export {
|
|
|
8
8
|
TransformHtmlArgs,
|
|
9
9
|
TransformHtmlFunction,
|
|
10
10
|
TransformAssetFunction,
|
|
11
|
-
} from './RollupPluginHTMLOptions';
|
|
11
|
+
} from './RollupPluginHTMLOptions.js';
|
|
12
12
|
|
|
13
13
|
export { rollupPluginHTML, RollupPluginHtml };
|
|
14
14
|
export default rollupPluginHTML;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InputOptions } from 'rollup';
|
|
2
|
-
import { ScriptModuleTag } from '../RollupPluginHTMLOptions';
|
|
3
|
-
import { createError } from '../utils';
|
|
2
|
+
import { ScriptModuleTag } from '../RollupPluginHTMLOptions.js';
|
|
3
|
+
import { createError } from '../utils.js';
|
|
4
4
|
|
|
5
5
|
function fromEntries<V>(entries: [string, V][]) {
|
|
6
6
|
const obj: Record<string, V> = {};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Document, serialize } from 'parse5';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
|
-
import { InputAsset } from '../InputData';
|
|
4
|
+
import { InputAsset } from '../InputData.js';
|
|
5
5
|
import {
|
|
6
6
|
findAssets,
|
|
7
7
|
getSourcePaths,
|
|
8
8
|
isHashedAsset,
|
|
9
9
|
resolveAssetFilePath,
|
|
10
|
-
} from '../../assets/utils';
|
|
10
|
+
} from '../../assets/utils.js';
|
|
11
11
|
|
|
12
12
|
export interface ExtractAssetsParams {
|
|
13
13
|
document: Document;
|
|
@@ -2,9 +2,9 @@ import { findElements, getAttribute, getTagName, getTextContent, remove } from '
|
|
|
2
2
|
import { Document, Attribute } from 'parse5';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import crypto from 'crypto';
|
|
5
|
-
import { resolveAssetFilePath } from '../../assets/utils';
|
|
5
|
+
import { resolveAssetFilePath } from '../../assets/utils.js';
|
|
6
6
|
import { getAttributes } from '@web/parse5-utils';
|
|
7
|
-
import { ScriptModuleTag } from '../../RollupPluginHTMLOptions';
|
|
7
|
+
import { ScriptModuleTag } from '../../RollupPluginHTMLOptions.js';
|
|
8
8
|
|
|
9
9
|
export interface ExtractModulesParams {
|
|
10
10
|
document: Document;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import { parse, serialize } from 'parse5';
|
|
3
|
-
import { extractModules } from './extractModules';
|
|
4
|
-
import { extractAssets } from './extractAssets';
|
|
3
|
+
import { extractModules } from './extractModules.js';
|
|
4
|
+
import { extractAssets } from './extractAssets.js';
|
|
5
5
|
|
|
6
6
|
export interface ExtractParams {
|
|
7
7
|
html: string;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import
|
|
3
|
+
import { globSync, GlobOptionsWithFileTypesFalse } from 'glob';
|
|
4
4
|
|
|
5
|
-
import { createError } from '../utils';
|
|
6
|
-
import { RollupPluginHTMLOptions } from '../RollupPluginHTMLOptions';
|
|
7
|
-
import { InputData } from './InputData';
|
|
8
|
-
import { normalizeInputOptions } from './normalizeInputOptions';
|
|
9
|
-
import { extractModulesAndAssets } from './extract/extractModulesAndAssets';
|
|
5
|
+
import { createError } from '../utils.js';
|
|
6
|
+
import { RollupPluginHTMLOptions } from '../RollupPluginHTMLOptions.js';
|
|
7
|
+
import { InputData } from './InputData.js';
|
|
8
|
+
import { normalizeInputOptions } from './normalizeInputOptions.js';
|
|
9
|
+
import { extractModulesAndAssets } from './extract/extractModulesAndAssets.js';
|
|
10
10
|
import { InputOption } from 'rollup';
|
|
11
11
|
|
|
12
|
-
function resolveGlob(fromGlob: string, opts:
|
|
13
|
-
const files =
|
|
12
|
+
function resolveGlob(fromGlob: string, opts: GlobOptionsWithFileTypesFalse) {
|
|
13
|
+
const files = globSync(fromGlob, { ...opts, absolute: true });
|
|
14
14
|
return (
|
|
15
15
|
files
|
|
16
16
|
// filter out directories
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InputOption } from 'rollup';
|
|
2
|
-
import { InputHTMLOptions, RollupPluginHTMLOptions } from '../RollupPluginHTMLOptions';
|
|
3
|
-
import { createError } from '../utils';
|
|
2
|
+
import { InputHTMLOptions, RollupPluginHTMLOptions } from '../RollupPluginHTMLOptions.js';
|
|
3
|
+
import { createError } from '../utils.js';
|
|
4
4
|
|
|
5
5
|
export function normalizeInputOptions(
|
|
6
6
|
pluginOptions: RollupPluginHTMLOptions,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { getEntrypointBundles } from './getEntrypointBundles';
|
|
2
|
-
import { getOutputHTML } from './getOutputHTML';
|
|
3
|
-
import { createError } from '../utils';
|
|
1
|
+
import { getEntrypointBundles } from './getEntrypointBundles.js';
|
|
2
|
+
import { getOutputHTML } from './getOutputHTML.js';
|
|
3
|
+
import { createError } from '../utils.js';
|
|
4
4
|
import {
|
|
5
5
|
GeneratedBundle,
|
|
6
6
|
RollupPluginHTMLOptions,
|
|
7
7
|
TransformHtmlFunction,
|
|
8
|
-
} from '../RollupPluginHTMLOptions';
|
|
8
|
+
} from '../RollupPluginHTMLOptions.js';
|
|
9
9
|
import { EmittedFile } from 'rollup';
|
|
10
|
-
import { InputData } from '../input/InputData';
|
|
11
|
-
import { EmittedAssets } from './emitAssets';
|
|
10
|
+
import { InputData } from '../input/InputData.js';
|
|
11
|
+
import { EmittedAssets } from './emitAssets.js';
|
|
12
12
|
|
|
13
13
|
export interface CreateHTMLAssetParams {
|
|
14
14
|
outputDir: string;
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
RollupPluginHTMLOptions,
|
|
9
9
|
ScriptModuleTag,
|
|
10
10
|
} from '../RollupPluginHTMLOptions';
|
|
11
|
-
import { createError, NOOP_IMPORT } from '../utils';
|
|
12
|
-
import { toBrowserPath } from './utils';
|
|
11
|
+
import { createError, NOOP_IMPORT } from '../utils.js';
|
|
12
|
+
import { toBrowserPath } from './utils.js';
|
|
13
13
|
|
|
14
14
|
export interface CreateImportPathParams {
|
|
15
15
|
publicPath?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { injectBundles } from './injectBundles';
|
|
1
|
+
import { injectBundles } from './injectBundles.js';
|
|
2
2
|
import { InputData } from '../input/InputData';
|
|
3
3
|
import {
|
|
4
4
|
EntrypointBundle,
|
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
} from '../RollupPluginHTMLOptions';
|
|
8
8
|
import { parse, serialize } from 'parse5';
|
|
9
9
|
import { minify as minifyHTMLFunc } from 'html-minifier-terser';
|
|
10
|
-
import { injectedUpdatedAssetPaths } from './injectedUpdatedAssetPaths';
|
|
11
|
-
import { EmittedAssets } from './emitAssets';
|
|
12
|
-
import { injectAbsoluteBaseUrl } from './injectAbsoluteBaseUrl';
|
|
13
|
-
import { hashInlineScripts } from './hashInlineScripts';
|
|
14
|
-
import { injectServiceWorkerRegistration } from './injectServiceWorkerRegistration';
|
|
10
|
+
import { injectedUpdatedAssetPaths } from './injectedUpdatedAssetPaths.js';
|
|
11
|
+
import { EmittedAssets } from './emitAssets.js';
|
|
12
|
+
import { injectAbsoluteBaseUrl } from './injectAbsoluteBaseUrl.js';
|
|
13
|
+
import { hashInlineScripts } from './hashInlineScripts.js';
|
|
14
|
+
import { injectServiceWorkerRegistration } from './injectServiceWorkerRegistration.js';
|
|
15
15
|
|
|
16
16
|
export interface GetOutputHTMLParams {
|
|
17
17
|
input: InputData;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Document, Attribute } from 'parse5';
|
|
2
2
|
import { createScript, findElement, getTagName, appendChild } from '@web/parse5-utils';
|
|
3
3
|
|
|
4
|
-
import { EntrypointBundle } from '../RollupPluginHTMLOptions';
|
|
5
|
-
import { createError } from '../utils';
|
|
4
|
+
import { EntrypointBundle } from '../RollupPluginHTMLOptions.js';
|
|
5
|
+
import { createError } from '../utils.js';
|
|
6
6
|
|
|
7
7
|
export function createLoadScript(src: string, format: string, attributes?: Attribute[]) {
|
|
8
8
|
const attributesObject: Record<string, string> = {};
|
|
@@ -8,11 +8,11 @@ import {
|
|
|
8
8
|
getSourcePaths,
|
|
9
9
|
isHashedAsset,
|
|
10
10
|
resolveAssetFilePath,
|
|
11
|
-
} from '../assets/utils';
|
|
12
|
-
import { InputData } from '../input/InputData';
|
|
13
|
-
import { createError } from '../utils';
|
|
14
|
-
import { EmittedAssets } from './emitAssets';
|
|
15
|
-
import { toBrowserPath } from './utils';
|
|
11
|
+
} from '../assets/utils.js';
|
|
12
|
+
import { InputData } from '../input/InputData.js';
|
|
13
|
+
import { createError } from '../utils.js';
|
|
14
|
+
import { EmittedAssets } from './emitAssets.js';
|
|
15
|
+
import { toBrowserPath } from './utils.js';
|
|
16
16
|
|
|
17
17
|
export interface InjectUpdatedAssetPathsArgs {
|
|
18
18
|
document: Document;
|
package/src/rollupPluginHTML.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { Plugin } from 'rollup';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
|
|
4
|
-
import { addRollupInput } from './input/addRollupInput';
|
|
5
|
-
import { getInputData } from './input/getInputData';
|
|
6
|
-
import { InputData } from './input/InputData';
|
|
7
|
-
import { createHTMLOutput } from './output/createHTMLOutput';
|
|
4
|
+
import { addRollupInput } from './input/addRollupInput.js';
|
|
5
|
+
import { getInputData } from './input/getInputData.js';
|
|
6
|
+
import { InputData } from './input/InputData.js';
|
|
7
|
+
import { createHTMLOutput } from './output/createHTMLOutput.js';
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
10
|
GeneratedBundle,
|
|
11
11
|
RollupPluginHTMLOptions,
|
|
12
12
|
ScriptModuleTag,
|
|
13
13
|
TransformHtmlFunction,
|
|
14
|
-
} from './RollupPluginHTMLOptions';
|
|
15
|
-
import { createError, NOOP_IMPORT } from './utils';
|
|
16
|
-
import { emitAssets } from './output/emitAssets';
|
|
14
|
+
} from './RollupPluginHTMLOptions.js';
|
|
15
|
+
import { createError, NOOP_IMPORT } from './utils.js';
|
|
16
|
+
import { emitAssets } from './output/emitAssets.js';
|
|
17
17
|
|
|
18
18
|
export interface RollupPluginHtml extends Plugin {
|
|
19
19
|
api: {
|
package/src/utils.ts
CHANGED