@web/rollup-plugin-html 0.0.0-canary-20230416222938 → 0.0.0-canary-20231122093600

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.
Files changed (86) hide show
  1. package/dist/RollupPluginHTMLOptions.d.ts +2 -2
  2. package/dist/RollupPluginHTMLOptions.d.ts.map +1 -1
  3. package/dist/RollupPluginHTMLOptions.js +1 -2
  4. package/dist/assets/utils.js +31 -43
  5. package/dist/assets/utils.js.map +1 -1
  6. package/dist/index.d.ts +2 -2
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +3 -6
  9. package/dist/index.js.map +1 -1
  10. package/dist/input/InputData.js +1 -2
  11. package/dist/input/addRollupInput.d.ts +1 -1
  12. package/dist/input/addRollupInput.d.ts.map +1 -1
  13. package/dist/input/addRollupInput.js +23 -16
  14. package/dist/input/addRollupInput.js.map +1 -1
  15. package/dist/input/extract/extractAssets.d.ts +1 -1
  16. package/dist/input/extract/extractAssets.d.ts.map +1 -1
  17. package/dist/input/extract/extractAssets.js +13 -20
  18. package/dist/input/extract/extractAssets.js.map +1 -1
  19. package/dist/input/extract/extractModules.d.ts +1 -1
  20. package/dist/input/extract/extractModules.d.ts.map +1 -1
  21. package/dist/input/extract/extractModules.js +16 -23
  22. package/dist/input/extract/extractModules.js.map +1 -1
  23. package/dist/input/extract/extractModulesAndAssets.d.ts +3 -3
  24. package/dist/input/extract/extractModulesAndAssets.js +10 -17
  25. package/dist/input/extract/extractModulesAndAssets.js.map +1 -1
  26. package/dist/input/getInputData.d.ts +2 -2
  27. package/dist/input/getInputData.d.ts.map +1 -1
  28. package/dist/input/getInputData.js +19 -27
  29. package/dist/input/getInputData.js.map +1 -1
  30. package/dist/input/normalizeInputOptions.d.ts +1 -1
  31. package/dist/input/normalizeInputOptions.d.ts.map +1 -1
  32. package/dist/input/normalizeInputOptions.js +5 -9
  33. package/dist/input/normalizeInputOptions.js.map +1 -1
  34. package/dist/output/createHTMLOutput.d.ts +3 -3
  35. package/dist/output/createHTMLOutput.d.ts.map +1 -1
  36. package/dist/output/createHTMLOutput.js +9 -14
  37. package/dist/output/createHTMLOutput.js.map +1 -1
  38. package/dist/output/emitAssets.js +4 -11
  39. package/dist/output/emitAssets.js.map +1 -1
  40. package/dist/output/getEntrypointBundles.js +12 -21
  41. package/dist/output/getEntrypointBundles.js.map +1 -1
  42. package/dist/output/getOutputHTML.d.ts +1 -1
  43. package/dist/output/getOutputHTML.d.ts.map +1 -1
  44. package/dist/output/getOutputHTML.js +20 -35
  45. package/dist/output/getOutputHTML.js.map +1 -1
  46. package/dist/output/hashInlineScripts.js +19 -23
  47. package/dist/output/hashInlineScripts.js.map +1 -1
  48. package/dist/output/injectAbsoluteBaseUrl.js +10 -14
  49. package/dist/output/injectAbsoluteBaseUrl.js.map +1 -1
  50. package/dist/output/injectBundles.d.ts +1 -1
  51. package/dist/output/injectBundles.d.ts.map +1 -1
  52. package/dist/output/injectBundles.js +10 -15
  53. package/dist/output/injectBundles.js.map +1 -1
  54. package/dist/output/injectServiceWorkerRegistration.js +10 -17
  55. package/dist/output/injectServiceWorkerRegistration.js.map +1 -1
  56. package/dist/output/injectedUpdatedAssetPaths.d.ts +2 -2
  57. package/dist/output/injectedUpdatedAssetPaths.d.ts.map +1 -1
  58. package/dist/output/injectedUpdatedAssetPaths.js +21 -28
  59. package/dist/output/injectedUpdatedAssetPaths.js.map +1 -1
  60. package/dist/output/utils.js +3 -10
  61. package/dist/output/utils.js.map +1 -1
  62. package/dist/rollupPluginHTML.d.ts +2 -2
  63. package/dist/rollupPluginHTML.d.ts.map +1 -1
  64. package/dist/rollupPluginHTML.js +24 -31
  65. package/dist/rollupPluginHTML.js.map +1 -1
  66. package/dist/utils.d.ts +1 -1
  67. package/dist/utils.d.ts.map +1 -1
  68. package/dist/utils.js +2 -6
  69. package/dist/utils.js.map +1 -1
  70. package/index.mjs +1 -4
  71. package/package.json +10 -8
  72. package/src/assets/utils.ts +1 -1
  73. package/src/index.ts +2 -2
  74. package/src/input/addRollupInput.ts +2 -2
  75. package/src/input/extract/extractAssets.ts +2 -2
  76. package/src/input/extract/extractModules.ts +2 -2
  77. package/src/input/extract/extractModulesAndAssets.ts +2 -2
  78. package/src/input/getInputData.ts +8 -8
  79. package/src/input/normalizeInputOptions.ts +2 -2
  80. package/src/output/createHTMLOutput.ts +6 -6
  81. package/src/output/getEntrypointBundles.ts +2 -2
  82. package/src/output/getOutputHTML.ts +6 -6
  83. package/src/output/injectBundles.ts +2 -2
  84. package/src/output/injectedUpdatedAssetPaths.ts +5 -5
  85. package/src/rollupPluginHTML.ts +7 -7
  86. package/src/utils.ts +1 -1
@@ -1,18 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.injectAbsoluteBaseUrl = void 0;
4
- const parse5_utils_1 = require("@web/parse5-utils");
1
+ import { findElements, getTagName, getAttribute, setAttribute } from '@web/parse5-utils';
5
2
  function isAbsoluteableNode(node) {
6
3
  const metaAttributes = ['og:url', 'og:image'];
7
- switch (parse5_utils_1.getTagName(node)) {
4
+ switch (getTagName(node)) {
8
5
  case 'link':
9
- if (parse5_utils_1.getAttribute(node, 'rel') === 'canonical' && parse5_utils_1.getAttribute(node, 'href')) {
6
+ if (getAttribute(node, 'rel') === 'canonical' && getAttribute(node, 'href')) {
10
7
  return true;
11
8
  }
12
9
  return false;
13
10
  case 'meta':
14
- if (metaAttributes.includes(parse5_utils_1.getAttribute(node, 'property')) &&
15
- parse5_utils_1.getAttribute(node, 'content')) {
11
+ if (metaAttributes.includes(getAttribute(node, 'property')) &&
12
+ getAttribute(node, 'content')) {
16
13
  return true;
17
14
  }
18
15
  return false;
@@ -20,18 +17,17 @@ function isAbsoluteableNode(node) {
20
17
  return false;
21
18
  }
22
19
  }
23
- function injectAbsoluteBaseUrl(document, absoluteBaseUrl) {
24
- const nodes = parse5_utils_1.findElements(document, isAbsoluteableNode);
20
+ export function injectAbsoluteBaseUrl(document, absoluteBaseUrl) {
21
+ const nodes = findElements(document, isAbsoluteableNode);
25
22
  for (const node of nodes) {
26
- switch (parse5_utils_1.getTagName(node)) {
23
+ switch (getTagName(node)) {
27
24
  case 'link':
28
- parse5_utils_1.setAttribute(node, 'href', new URL(parse5_utils_1.getAttribute(node, 'href'), absoluteBaseUrl).href);
25
+ setAttribute(node, 'href', new URL(getAttribute(node, 'href'), absoluteBaseUrl).href);
29
26
  break;
30
27
  case 'meta':
31
- parse5_utils_1.setAttribute(node, 'content', new URL(parse5_utils_1.getAttribute(node, 'content'), absoluteBaseUrl).href);
28
+ setAttribute(node, 'content', new URL(getAttribute(node, 'content'), absoluteBaseUrl).href);
32
29
  break;
33
30
  }
34
31
  }
35
32
  }
36
- exports.injectAbsoluteBaseUrl = injectAbsoluteBaseUrl;
37
33
  //# sourceMappingURL=injectAbsoluteBaseUrl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"injectAbsoluteBaseUrl.js","sourceRoot":"","sources":["../../src/output/injectAbsoluteBaseUrl.ts"],"names":[],"mappings":";;;AACA,oDAAyF;AAEzF,SAAS,kBAAkB,CAAC,IAAa;IACvC,MAAM,cAAc,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAC9C,QAAQ,yBAAU,CAAC,IAAI,CAAC,EAAE;QACxB,KAAK,MAAM;YACT,IAAI,2BAAY,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,WAAW,IAAI,2BAAY,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE;gBAC3E,OAAO,IAAI,CAAC;aACb;YACD,OAAO,KAAK,CAAC;QACf,KAAK,MAAM;YACT,IACE,cAAc,CAAC,QAAQ,CAAC,2BAAY,CAAC,IAAI,EAAE,UAAU,CAAE,CAAC;gBACxD,2BAAY,CAAC,IAAI,EAAE,SAAS,CAAC,EAC7B;gBACA,OAAO,IAAI,CAAC;aACb;YACD,OAAO,KAAK,CAAC;QACf;YACE,OAAO,KAAK,CAAC;KAChB;AACH,CAAC;AAED,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AAO,IAAI,CAAC;aACb;YACD,OAAO,KAAK,CAAC;QACf;YACE,OAAO,KAAK,CAAC;KAChB;AACH,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,QAAkB,EAAE,eAAuB;IAC/E,MAAM,KAAK,GAAG,YAAY,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;IACzD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,QAAQ,UAAU,CAAC,IAAI,CAAC,EAAE;YACxB,KAAK,MAAM;gBACT,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAE,EAAE,eAAe,CAAC,CAAC,IAAI,CAAC,CAAC;gBACvF,MAAM;YACR,KAAK,MAAM;gBACT,YAAY,CACV,IAAI,EACJ,SAAS,EACT,IAAI,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,SAAS,CAAE,EAAE,eAAe,CAAC,CAAC,IAAI,CAC9D,CAAC;gBACF,MAAM;SACT;KACF;AACH,CAAC"}
@@ -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,4BAA4B,CAAC;AAG9D,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"}
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"}
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.injectBundles = exports.createLoadScript = void 0;
4
- const parse5_utils_1 = require("@web/parse5-utils");
5
- const utils_1 = require("../utils");
6
- function createLoadScript(src, format, attributes) {
1
+ import { createScript, findElement, getTagName, appendChild } from '@web/parse5-utils';
2
+ import { createError } from '../utils.js';
3
+ export function createLoadScript(src, format, attributes) {
7
4
  const attributesObject = {};
8
5
  if (attributes) {
9
6
  for (const attribute of attributes) {
@@ -11,26 +8,24 @@ function createLoadScript(src, format, attributes) {
11
8
  }
12
9
  }
13
10
  if (['es', 'esm', 'module'].includes(format)) {
14
- return parse5_utils_1.createScript(Object.assign({ type: 'module', src }, attributesObject));
11
+ return createScript({ type: 'module', src, ...attributesObject });
15
12
  }
16
13
  if (['system', 'systemjs'].includes(format)) {
17
- return parse5_utils_1.createScript({}, `System.import(${JSON.stringify(src)});`);
14
+ return createScript({}, `System.import(${JSON.stringify(src)});`);
18
15
  }
19
- return parse5_utils_1.createScript({ src, defer: '' });
16
+ return createScript({ src, defer: '' });
20
17
  }
21
- exports.createLoadScript = createLoadScript;
22
- function injectBundles(document, entrypointBundles) {
23
- const body = parse5_utils_1.findElement(document, e => parse5_utils_1.getTagName(e) === 'body');
18
+ export function injectBundles(document, entrypointBundles) {
19
+ const body = findElement(document, e => getTagName(e) === 'body');
24
20
  if (!body) {
25
21
  throw new Error('Missing body in HTML document.');
26
22
  }
27
23
  for (const { options, entrypoints } of Object.values(entrypointBundles)) {
28
24
  if (!options.format)
29
- throw utils_1.createError('Missing output format.');
25
+ throw createError('Missing output format.');
30
26
  for (const entrypoint of entrypoints) {
31
- parse5_utils_1.appendChild(body, createLoadScript(entrypoint.importPath, options.format, entrypoint.attributes));
27
+ appendChild(body, createLoadScript(entrypoint.importPath, options.format, entrypoint.attributes));
32
28
  }
33
29
  }
34
30
  }
35
- exports.injectBundles = injectBundles;
36
31
  //# sourceMappingURL=injectBundles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"injectBundles.js","sourceRoot":"","sources":["../../src/output/injectBundles.ts"],"names":[],"mappings":";;;AACA,oDAAuF;AAGvF,oCAAuC;AAEvC,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,2BAAY,iBAAG,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,2BAAY,CAAC,EAAE,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{
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.injectServiceWorkerRegistration = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const parse5_utils_1 = require("@web/parse5-utils");
9
- function injectServiceWorkerRegistration(args) {
1
+ import path from 'path';
2
+ import { findElement, getTagName, appendChild, createScript, setAttribute, } from '@web/parse5-utils';
3
+ export function injectServiceWorkerRegistration(args) {
10
4
  const { document, serviceWorkerPath, outputDir, htmlFileName } = args;
11
- const body = parse5_utils_1.findElement(document, e => parse5_utils_1.getTagName(e) === 'body');
5
+ const body = findElement(document, e => getTagName(e) === 'body');
12
6
  if (!body) {
13
7
  throw new Error('Missing body in HTML document.');
14
8
  }
15
- let serviceWorkerUrl = path_1.default.relative(outputDir, serviceWorkerPath);
16
- serviceWorkerUrl = path_1.default.relative(path_1.default.dirname(htmlFileName), serviceWorkerUrl);
17
- serviceWorkerUrl = serviceWorkerUrl.split(path_1.default.sep).join('/');
9
+ let serviceWorkerUrl = path.relative(outputDir, serviceWorkerPath);
10
+ serviceWorkerUrl = path.relative(path.dirname(htmlFileName), serviceWorkerUrl);
11
+ serviceWorkerUrl = serviceWorkerUrl.split(path.sep).join('/');
18
12
  const code = `
19
13
  if ('serviceWorker' in navigator) {
20
14
  window.addEventListener('load', function() {
@@ -29,9 +23,8 @@ function injectServiceWorkerRegistration(args) {
29
23
  });
30
24
  }
31
25
  `;
32
- const script = parse5_utils_1.createScript({}, code);
33
- parse5_utils_1.setAttribute(script, 'inject-service-worker', '');
34
- parse5_utils_1.appendChild(body, script);
26
+ const script = createScript({}, code);
27
+ setAttribute(script, 'inject-service-worker', '');
28
+ appendChild(body, script);
35
29
  }
36
- exports.injectServiceWorkerRegistration = injectServiceWorkerRegistration;
37
30
  //# sourceMappingURL=injectServiceWorkerRegistration.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"injectServiceWorkerRegistration.js","sourceRoot":"","sources":["../../src/output/injectServiceWorkerRegistration.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAExB,oDAM2B;AAS3B,SAAgB,+BAA+B,CAAC,IAAyC;IACvF,MAAM,EAAE,QAAQ,EAAE,iBAAiB,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IACtE,MAAM,IAAI,GAAG,0BAAW,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,yBAAU,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC;IAClE,IAAI,CAAC,IAAI,EAAE;QACT,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;KACnD;IAED,IAAI,gBAAgB,GAAG,cAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC;IACnE,gBAAgB,GAAG,cAAI,CAAC,QAAQ,CAAC,cAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,gBAAgB,CAAC,CAAC;IAC/E,gBAAgB,GAAG,gBAAgB,CAAC,KAAK,CAAC,cAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAE9D,MAAM,IAAI,GAAG;;;;uBAIQ,gBAAgB;;0DAEmB,gBAAgB;;;;;;;GAOvE,CAAC;IAEF,MAAM,MAAM,GAAG,2BAAY,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IACtC,2BAAY,CAAC,MAAM,EAAE,uBAAuB,EAAE,EAAE,CAAC,CAAC;IAElD,0BAAW,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC5B,CAAC;AA9BD,0EA8BC"}
1
+ {"version":3,"file":"injectServiceWorkerRegistration.js","sourceRoot":"","sources":["../../src/output/injectServiceWorkerRegistration.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EACL,WAAW,EACX,UAAU,EACV,WAAW,EACX,YAAY,EACZ,YAAY,GACb,MAAM,mBAAmB,CAAC;AAS3B,MAAM,UAAU,+BAA+B,CAAC,IAAyC;IACvF,MAAM,EAAE,QAAQ,EAAE,iBAAiB,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IACtE,MAAM,IAAI,GAAG,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC;IAClE,IAAI,CAAC,IAAI,EAAE;QACT,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;KACnD;IAED,IAAI,gBAAgB,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC;IACnE,gBAAgB,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,gBAAgB,CAAC,CAAC;IAC/E,gBAAgB,GAAG,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAE9D,MAAM,IAAI,GAAG;;;;uBAIQ,gBAAgB;;0DAEmB,gBAAgB;;;;;;;GAOvE,CAAC;IAEF,MAAM,MAAM,GAAG,YAAY,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IACtC,YAAY,CAAC,MAAM,EAAE,uBAAuB,EAAE,EAAE,CAAC,CAAC;IAElD,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC5B,CAAC"}
@@ -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,oBAAoB,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,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"}
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"}
@@ -1,14 +1,8 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.injectedUpdatedAssetPaths = void 0;
7
- const parse5_utils_1 = require("@web/parse5-utils");
8
- const path_1 = __importDefault(require("path"));
9
- const utils_1 = require("../assets/utils");
10
- const utils_2 = require("../utils");
11
- const utils_3 = require("./utils");
1
+ import { getAttribute, setAttribute } from '@web/parse5-utils';
2
+ import path from 'path';
3
+ import { findAssets, getSourceAttribute, getSourcePaths, isHashedAsset, resolveAssetFilePath, } from '../assets/utils.js';
4
+ import { createError } from '../utils.js';
5
+ import { toBrowserPath } from './utils.js';
12
6
  function getSrcSetUrlWidthPairs(srcset) {
13
7
  if (!srcset) {
14
8
  return [];
@@ -19,29 +13,29 @@ function getSrcSetUrlWidthPairs(srcset) {
19
13
  .map(url => (url.includes(' ') ? url.split(' ') : [url]));
20
14
  return urls;
21
15
  }
22
- function injectedUpdatedAssetPaths(args) {
16
+ export function injectedUpdatedAssetPaths(args) {
23
17
  const { document, input, outputDir, rootDir, emittedAssets, publicPath = './', absolutePathPrefix, } = args;
24
- const assetNodes = utils_1.findAssets(document);
18
+ const assetNodes = findAssets(document);
25
19
  for (const node of assetNodes) {
26
- const sourcePaths = utils_1.getSourcePaths(node);
20
+ const sourcePaths = getSourcePaths(node);
27
21
  for (const sourcePath of sourcePaths) {
28
- const htmlFilePath = input.filePath ? input.filePath : path_1.default.join(rootDir, input.name);
29
- const htmlDir = path_1.default.dirname(htmlFilePath);
30
- const filePath = utils_1.resolveAssetFilePath(sourcePath, htmlDir, rootDir, absolutePathPrefix);
31
- const assetPaths = utils_1.isHashedAsset(node) ? emittedAssets.hashed : emittedAssets.static;
22
+ const htmlFilePath = input.filePath ? input.filePath : path.join(rootDir, input.name);
23
+ const htmlDir = path.dirname(htmlFilePath);
24
+ const filePath = resolveAssetFilePath(sourcePath, htmlDir, rootDir, absolutePathPrefix);
25
+ const assetPaths = isHashedAsset(node) ? emittedAssets.hashed : emittedAssets.static;
32
26
  const relativeOutputPath = assetPaths.get(filePath);
33
27
  if (!relativeOutputPath) {
34
- throw utils_2.createError(`Something went wrong while bundling HTML file ${input.name}. Could not find ${filePath} in emitted rollup assets.`);
28
+ throw createError(`Something went wrong while bundling HTML file ${input.name}. Could not find ${filePath} in emitted rollup assets.`);
35
29
  }
36
- const htmlOutputFilePath = path_1.default.join(outputDir, input.name);
37
- const htmlOutputDir = path_1.default.dirname(htmlOutputFilePath);
38
- const absoluteOutputPath = path_1.default.join(outputDir, relativeOutputPath);
39
- const relativePathToHtmlFile = path_1.default.relative(htmlOutputDir, absoluteOutputPath);
40
- const browserPath = path_1.default.posix.join(publicPath, utils_3.toBrowserPath(relativePathToHtmlFile));
41
- const key = utils_1.getSourceAttribute(node);
30
+ const htmlOutputFilePath = path.join(outputDir, input.name);
31
+ const htmlOutputDir = path.dirname(htmlOutputFilePath);
32
+ const absoluteOutputPath = path.join(outputDir, relativeOutputPath);
33
+ const relativePathToHtmlFile = path.relative(htmlOutputDir, absoluteOutputPath);
34
+ const browserPath = path.posix.join(publicPath, toBrowserPath(relativePathToHtmlFile));
35
+ const key = getSourceAttribute(node);
42
36
  let newAttributeValue = browserPath;
43
37
  if (key === 'srcset') {
44
- const srcset = parse5_utils_1.getAttribute(node, key);
38
+ const srcset = getAttribute(node, key);
45
39
  if (srcset) {
46
40
  const urlWidthPairs = getSrcSetUrlWidthPairs(srcset);
47
41
  for (const urlWidthPair of urlWidthPairs) {
@@ -52,9 +46,8 @@ function injectedUpdatedAssetPaths(args) {
52
46
  newAttributeValue = urlWidthPairs.map(urlWidthPair => urlWidthPair.join(' ')).join(', ');
53
47
  }
54
48
  }
55
- parse5_utils_1.setAttribute(node, key, newAttributeValue);
49
+ setAttribute(node, key, newAttributeValue);
56
50
  }
57
51
  }
58
52
  }
59
- exports.injectedUpdatedAssetPaths = injectedUpdatedAssetPaths;
60
53
  //# sourceMappingURL=injectedUpdatedAssetPaths.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"injectedUpdatedAssetPaths.js","sourceRoot":"","sources":["../../src/output/injectedUpdatedAssetPaths.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA+D;AAE/D,gDAAwB;AAEx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AAC;YACvD,MAAM,kBAAkB,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;YACpE,MAAM,sBAAsB,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC;YAEhF,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,sBAAsB,CAAC,CAAC,CAAC;YACvF,MAAM,GAAG,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;YAErC,IAAI,iBAAiB,GAAG,WAAW,CAAC;YACpC,IAAI,GAAG,KAAK,QAAQ,EAAE;gBACpB,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;gBACvC,IAAI,MAAM,EAAE;oBACV,MAAM,aAAa,GAAG,sBAAsB,CAAC,MAAM,CAAC,CAAC;oBACrD,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE;wBACxC,IAAI,YAAY,CAAC,CAAC,CAAC,KAAK,UAAU,EAAE;4BAClC,YAAY,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC;yBAC/B;qBACF;oBACD,iBAAiB,GAAG,aAAa,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;iBAC1F;aACF;YAED,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,iBAAiB,CAAC,CAAC;SAC5C;KACF;AACH,CAAC"}
@@ -1,12 +1,5 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.toBrowserPath = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- function toBrowserPath(filePath) {
9
- return filePath.split(path_1.default.sep).join('/');
1
+ import path from 'path';
2
+ export function toBrowserPath(filePath) {
3
+ return filePath.split(path.sep).join('/');
10
4
  }
11
- exports.toBrowserPath = toBrowserPath;
12
5
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/output/utils.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAExB,SAAgB,aAAa,CAAC,QAAgB;IAC5C,OAAO,QAAQ,CAAC,KAAK,CAAC,cAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC5C,CAAC;AAFD,sCAEC"}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/output/utils.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,UAAU,aAAa,CAAC,QAAgB;IAC5C,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC5C,CAAC"}
@@ -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,mBAAmB,CAAC;AAG9C,OAAO,EAEL,uBAAuB,EAEvB,qBAAqB,EACtB,MAAM,2BAA2B,CAAC;AAInC,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"}
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"}
@@ -1,16 +1,10 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.rollupPluginHTML = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const addRollupInput_1 = require("./input/addRollupInput");
9
- const getInputData_1 = require("./input/getInputData");
10
- const createHTMLOutput_1 = require("./output/createHTMLOutput");
11
- const utils_1 = require("./utils");
12
- const emitAssets_1 = require("./output/emitAssets");
13
- function rollupPluginHTML(pluginOptions = {}) {
1
+ import path from 'path';
2
+ import { addRollupInput } from './input/addRollupInput.js';
3
+ import { getInputData } from './input/getInputData.js';
4
+ import { createHTMLOutput } from './output/createHTMLOutput.js';
5
+ import { createError, NOOP_IMPORT } from './utils.js';
6
+ import { emitAssets } from './output/emitAssets.js';
7
+ export function rollupPluginHTML(pluginOptions = {}) {
14
8
  const multiOutputNames = [];
15
9
  let inputs = [];
16
10
  let generatedBundles = [];
@@ -29,7 +23,7 @@ function rollupPluginHTML(pluginOptions = {}) {
29
23
  name: '@web/rollup-plugin-html',
30
24
  options(inputOptions) {
31
25
  reset();
32
- inputs = getInputData_1.getInputData(pluginOptions, inputOptions.input);
26
+ inputs = getInputData(pluginOptions, inputOptions.input);
33
27
  const moduleImports = [];
34
28
  for (const input of inputs) {
35
29
  moduleImports.push(...input.moduleImports);
@@ -37,7 +31,7 @@ function rollupPluginHTML(pluginOptions = {}) {
37
31
  if (moduleImports.length === 0) {
38
32
  // if there are only pages with pure HTML we need to make sure there is at
39
33
  // least some input for rollup
40
- moduleImports.push(utils_1.NOOP_IMPORT);
34
+ moduleImports.push(NOOP_IMPORT);
41
35
  }
42
36
  if (pluginOptions.serviceWorkerPath) {
43
37
  serviceWorkerPath = pluginOptions.serviceWorkerPath;
@@ -53,11 +47,11 @@ function rollupPluginHTML(pluginOptions = {}) {
53
47
  }
54
48
  if (pluginOptions.input == null) {
55
49
  // we are reading rollup input, so replace whatever was there
56
- return Object.assign(Object.assign({}, inputOptions), { input: moduleImports.map(mod => mod.importPath) });
50
+ return { ...inputOptions, input: moduleImports.map(mod => mod.importPath) };
57
51
  }
58
52
  else {
59
53
  // we need to add modules to existing rollup input
60
- return addRollupInput_1.addRollupInput(inputOptions, moduleImports);
54
+ return addRollupInput(inputOptions, moduleImports);
61
55
  }
62
56
  },
63
57
  /** Watch input files when running in watch mode */
@@ -74,8 +68,8 @@ function rollupPluginHTML(pluginOptions = {}) {
74
68
  },
75
69
  /** Notifies rollup that we will be handling these modules */
76
70
  resolveId(id) {
77
- if (id === utils_1.NOOP_IMPORT.importPath) {
78
- return utils_1.NOOP_IMPORT.importPath;
71
+ if (id === NOOP_IMPORT.importPath) {
72
+ return NOOP_IMPORT.importPath;
79
73
  }
80
74
  for (const input of inputs) {
81
75
  if (input.inlineModules.find(mod => mod.importPath === id)) {
@@ -85,7 +79,7 @@ function rollupPluginHTML(pluginOptions = {}) {
85
79
  },
86
80
  /** Provide code for modules we are handling */
87
81
  load(id) {
88
- if (id === utils_1.NOOP_IMPORT.importPath) {
82
+ if (id === NOOP_IMPORT.importPath) {
89
83
  return 'export default "noop"';
90
84
  }
91
85
  for (const input of inputs) {
@@ -106,12 +100,12 @@ function rollupPluginHTML(pluginOptions = {}) {
106
100
  return;
107
101
  }
108
102
  if (!options.dir) {
109
- throw utils_1.createError('Rollup output options must have a dir option set to emit an HTML file.');
103
+ throw createError('Rollup output options must have a dir option set to emit an HTML file.');
110
104
  }
111
105
  generatedBundles.push({ name: 'default', options, bundle });
112
- const emittedAssets = await emitAssets_1.emitAssets.call(this, inputs, pluginOptions);
113
- const outputs = await createHTMLOutput_1.createHTMLOutput({
114
- outputDir: path_1.default.resolve(options.dir),
106
+ const emittedAssets = await emitAssets.call(this, inputs, pluginOptions);
107
+ const outputs = await createHTMLOutput({
108
+ outputDir: path.resolve(options.dir),
115
109
  inputs,
116
110
  emittedAssets,
117
111
  generatedBundles,
@@ -139,25 +133,25 @@ function rollupPluginHTML(pluginOptions = {}) {
139
133
  },
140
134
  addOutput(name) {
141
135
  if (!name || multiOutputNames.includes(name)) {
142
- throw utils_1.createError('Each output must have a unique name');
136
+ throw createError('Each output must have a unique name');
143
137
  }
144
138
  multiOutputNames.push(name);
145
139
  return {
146
140
  name: `@web/rollup-plugin-html-multi-output-${multiOutputNames.length}`,
147
141
  async generateBundle(options, bundle) {
148
142
  if (!options.dir) {
149
- throw utils_1.createError(`Output ${name} must have a dir option set.`);
143
+ throw createError(`Output ${name} must have a dir option set.`);
150
144
  }
151
145
  generatedBundles.push({ name, options, bundle });
152
146
  if (generatedBundles.length === multiOutputNames.length) {
153
147
  // this is the last build, emit the HTML files
154
148
  const outputDirs = new Set(generatedBundles.map(b => b.options.dir));
155
149
  if (outputDirs.size !== 1) {
156
- throw utils_1.createError('Unable to emit HTML output. Multiple rollup build outputs have a different output directory set.');
150
+ throw createError('Unable to emit HTML output. Multiple rollup build outputs have a different output directory set.');
157
151
  }
158
- const emittedAssets = await emitAssets_1.emitAssets.call(this, inputs, pluginOptions);
159
- const outputs = await createHTMLOutput_1.createHTMLOutput({
160
- outputDir: path_1.default.resolve(options.dir),
152
+ const emittedAssets = await emitAssets.call(this, inputs, pluginOptions);
153
+ const outputs = await createHTMLOutput({
154
+ outputDir: path.resolve(options.dir),
161
155
  inputs,
162
156
  emittedAssets,
163
157
  generatedBundles,
@@ -179,5 +173,4 @@ function rollupPluginHTML(pluginOptions = {}) {
179
173
  },
180
174
  };
181
175
  }
182
- exports.rollupPluginHTML = rollupPluginHTML;
183
176
  //# sourceMappingURL=rollupPluginHTML.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rollupPluginHTML.js","sourceRoot":"","sources":["../src/rollupPluginHTML.ts"],"names":[],"mappings":";;;;;;AACA,gDAAwB;AAExB,2DAAwD;AACxD,uDAAoD;AAEpD,gEAA6D;AAQ7D,mCAAmD;AACnD,oDAAiD;AAWjD,SAAgB,gBAAgB,CAAC,gBAAyC,EAAE;IAC1E,MAAM,gBAAgB,GAAa,EAAE,CAAC;IACtC,IAAI,MAAM,GAAgB,EAAE,CAAC;IAC7B,IAAI,gBAAgB,GAAsB,EAAE,CAAC;IAC7C,IAAI,wBAAwB,GAA4B,EAAE,CAAC;IAC3D,IAAI,qBAAqB,GAAG,KAAK,CAAC;IAClC,IAAI,iBAAiB,GAAG,EAAE,CAAC;IAC3B,IAAI,mBAAmB,GAAG,KAAK,CAAC;IAChC,IAAI,kBAA0B,CAAC;IAC/B,IAAI,sBAAsB,GAAG,KAAK,CAAC;IAEnC,SAAS,KAAK;QACZ,M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CACpC,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"}
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
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAI5D,eAAO,MAAM,WAAW,EAAE,eAAgE,CAAC;AAE3F,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,SAEtC"}
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/dist/utils.js CHANGED
@@ -1,10 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createError = exports.NOOP_IMPORT = void 0;
4
1
  const PLUGIN = '[@web/rollup-plugin-html]';
5
- exports.NOOP_IMPORT = { importPath: '@web/rollup-plugin-html-noop' };
6
- function createError(msg) {
2
+ export const NOOP_IMPORT = { importPath: '@web/rollup-plugin-html-noop' };
3
+ export function createError(msg) {
7
4
  return new Error(`${PLUGIN} ${msg}`);
8
5
  }
9
- exports.createError = createError;
10
6
  //# sourceMappingURL=utils.js.map
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAEA,MAAM,MAAM,GAAG,2BAA2B,CAAC;AAE9B,QAAA,WAAW,GAAoB,EAAE,UAAU,EAAE,8BAA8B,EAAE,CAAC;AAE3F,SAAgB,WAAW,CAAC,GAAW;IACrC,OAAO,IAAI,KAAK,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC;AACvC,CAAC;AAFD,kCAEC"}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAG,2BAA2B,CAAC;AAE3C,MAAM,CAAC,MAAM,WAAW,GAAoB,EAAE,UAAU,EAAE,8BAA8B,EAAE,CAAC;AAE3F,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,OAAO,IAAI,KAAK,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC;AACvC,CAAC"}
package/index.mjs CHANGED
@@ -1,6 +1,3 @@
1
1
  // this file is autogenerated with the generate-mjs-dts-entrypoints script
2
- import cjsEntrypoint from './dist/index.js';
3
2
 
4
- const { rollupPluginHTML } = cjsEntrypoint;
5
-
6
- export { rollupPluginHTML };
3
+ export { rollupPluginHTML } from './dist/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@web/rollup-plugin-html",
3
- "version": "0.0.0-canary-20230416222938",
3
+ "version": "0.0.0-canary-20231122093600",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -14,18 +14,20 @@
14
14
  "author": "modern-web",
15
15
  "homepage": "https://github.com/modernweb-dev/web/tree/master/packages/rollup-plugin-html",
16
16
  "main": "dist/index.js",
17
+ "type": "module",
17
18
  "exports": {
18
19
  ".": {
19
20
  "import": "./index.mjs",
20
- "require": "./dist/index.js"
21
+ "require": "./dist/index.js",
22
+ "types": "./dist/index.d.ts"
21
23
  }
22
24
  },
23
25
  "engines": {
24
- "node": ">=16.0.0"
26
+ "node": ">=18.0.0"
25
27
  },
26
28
  "scripts": {
27
- "demo:mpa": "rm -rf demo/dist && rollup -c demo/mpa/rollup.config.js --watch & yarn serve-demo",
28
- "demo:spa": "rm -rf demo/dist && rollup -c demo/spa/rollup.config.js --watch & yarn serve-demo",
29
+ "demo:mpa": "rm -rf demo/dist && rollup -c demo/mpa/rollup.config.js --watch & npm run serve-demo",
30
+ "demo:spa": "rm -rf demo/dist && rollup -c demo/spa/rollup.config.js --watch & npm run serve-demo",
29
31
  "serve-demo": "node ../dev-server/dist/bin.js --watch --root-dir demo/dist --app-index index.html --compatibility none --open",
30
32
  "test": "mocha test/**/*.test.ts --require ts-node/register",
31
33
  "test:watch": "mocha test/**/*.test.ts --require ts-node/register --watch --watch-files src,test"
@@ -43,13 +45,13 @@
43
45
  "html"
44
46
  ],
45
47
  "dependencies": {
46
- "@web/parse5-utils": "0.0.0-canary-20230416222938",
47
- "glob": "^7.1.6",
48
+ "@web/parse5-utils": "0.0.0-canary-20231122093600",
49
+ "glob": "^10.0.0",
48
50
  "html-minifier-terser": "^7.1.0",
49
51
  "parse5": "^6.0.1"
50
52
  },
51
53
  "devDependencies": {
52
54
  "@types/html-minifier-terser": "^7.0.0",
53
- "rollup": "^3.15.0"
55
+ "rollup": "^4.4.0"
54
56
  }
55
57
  }
@@ -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> = {};