@atlaspack/packager-html 2.14.5-canary.172 → 2.14.5-canary.174

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.
@@ -64,10 +64,8 @@ var _default = exports.default = new (_plugin().Packager)({
64
64
  packageKey: '@atlaspack/packager-html'
65
65
  });
66
66
  return {
67
- // @ts-expect-error TS2339
68
67
  render: posthtmlConfig === null || posthtmlConfig === void 0 || (_posthtmlConfig$conte = posthtmlConfig.contents) === null || _posthtmlConfig$conte === void 0 ? void 0 : _posthtmlConfig$conte.render,
69
- evaluateRootConditionalBundles: Boolean( // @ts-expect-error TS2339
70
- conf === null || conf === void 0 || (_conf$contents = conf.contents) === null || _conf$contents === void 0 ? void 0 : _conf$contents.evaluateRootConditionalBundles)
68
+ evaluateRootConditionalBundles: Boolean(conf === null || conf === void 0 || (_conf$contents = conf.contents) === null || _conf$contents === void 0 ? void 0 : _conf$contents.evaluateRootConditionalBundles)
71
69
  };
72
70
  },
73
71
  async package({
@@ -76,7 +74,6 @@ var _default = exports.default = new (_plugin().Packager)({
76
74
  getInlineBundleContents,
77
75
  config
78
76
  }) {
79
- // @ts-expect-error TS2552
80
77
  let assets = [];
81
78
  bundle.traverseAssets(asset => {
82
79
  assets.push(asset);
@@ -95,9 +92,7 @@ var _default = exports.default = new (_plugin().Packager)({
95
92
  let renderConfig = config === null || config === void 0 ? void 0 : config.render;
96
93
  let {
97
94
  html
98
- } = await (0, _posthtml().default)([tree => insertBundleReferences(
99
- // @ts-expect-error TS2345
100
- [...conditionalBundles, ...referencedBundles], tree, conditionalBundles), tree => replaceInlineAssetContent(bundleGraph, getInlineBundleContents, tree)]).process(code, {
95
+ } = await (0, _posthtml().default)([tree => insertBundleReferences([...conditionalBundles, ...referencedBundles], tree, conditionalBundles), tree => replaceInlineAssetContent(bundleGraph, getInlineBundleContents, tree)]).process(code, {
101
96
  ...renderConfig,
102
97
  xmlMode: bundle.type === 'xhtml',
103
98
  closingSingleTag: bundle.type === 'xhtml' ? 'slash' : undefined
@@ -147,7 +142,6 @@ async function getAssetContent(bundleGraph, getInlineBundleContents, assetId) {
147
142
  }
148
143
  async function replaceInlineAssetContent(bundleGraph, getInlineBundleContents, tree) {
149
144
  const inlineNodes = [];
150
- // @ts-expect-error TS7006
151
145
  tree.walk(node => {
152
146
  if (node.attrs && node.attrs['data-parcel-key']) {
153
147
  inlineNodes.push(node);
@@ -212,8 +206,6 @@ function insertBundleReferences(siblingBundles, tree, conditionalBundles) {
212
206
  }
213
207
  addBundlesToTree(bundles, tree);
214
208
  }
215
-
216
- // @ts-expect-error TS7006
217
209
  function addBundlesToTree(bundles, tree) {
218
210
  const main = find(tree, 'head') || find(tree, 'html');
219
211
  // @ts-expect-error TS2339
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/packager-html",
3
- "version": "2.14.5-canary.172+88439807b",
3
+ "version": "2.14.5-canary.174+a5081c3f9",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -16,10 +16,10 @@
16
16
  "node": ">= 16.0.0"
17
17
  },
18
18
  "dependencies": {
19
- "@atlaspack/feature-flags": "2.14.1-canary.240+88439807b",
20
- "@atlaspack/plugin": "2.14.5-canary.172+88439807b",
21
- "@atlaspack/types": "2.14.5-canary.172+88439807b",
22
- "@atlaspack/utils": "2.14.5-canary.172+88439807b",
19
+ "@atlaspack/feature-flags": "2.14.1-canary.242+a5081c3f9",
20
+ "@atlaspack/plugin": "2.14.5-canary.174+a5081c3f9",
21
+ "@atlaspack/types": "2.14.5-canary.174+a5081c3f9",
22
+ "@atlaspack/utils": "2.14.5-canary.174+a5081c3f9",
23
23
  "nullthrows": "^1.1.1",
24
24
  "posthtml": "^0.16.5"
25
25
  },
@@ -28,5 +28,5 @@
28
28
  "check-ts": "tsc --emitDeclarationOnly --rootDir src",
29
29
  "build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
30
30
  },
31
- "gitHead": "88439807be20025fd3433380204ff1205079729e"
31
+ "gitHead": "a5081c3f9207d28716ee4edd3841de1830ea4b80"
32
32
  }
@@ -1,4 +1,11 @@
1
- import type {Bundle, BundleGraph, NamedBundle} from '@atlaspack/types';
1
+ import type {
2
+ Asset,
3
+ Async,
4
+ Blob,
5
+ Bundle,
6
+ BundleGraph,
7
+ NamedBundle,
8
+ } from '@atlaspack/types';
2
9
 
3
10
  import assert from 'assert';
4
11
  import {Readable} from 'stream';
@@ -25,9 +32,15 @@ const metadataContent = new Set([
25
32
  'title',
26
33
  ]);
27
34
 
35
+ type HTMLPackagerConfig = {
36
+ evaluateRootConditionalBundles: boolean;
37
+ };
38
+
28
39
  export default new Packager({
29
40
  async loadConfig({config, options}) {
30
- let posthtmlConfig = await config.getConfig(
41
+ let posthtmlConfig = await config.getConfig<{
42
+ render: any;
43
+ }>(
31
44
  [
32
45
  '.posthtmlrc',
33
46
  '.posthtmlrc.js',
@@ -42,21 +55,22 @@ export default new Packager({
42
55
  },
43
56
  );
44
57
 
45
- let conf = await config.getConfigFrom(options.projectRoot + '/index', [], {
46
- packageKey: '@atlaspack/packager-html',
47
- });
58
+ let conf = await config.getConfigFrom<HTMLPackagerConfig>(
59
+ options.projectRoot + '/index',
60
+ [],
61
+ {
62
+ packageKey: '@atlaspack/packager-html',
63
+ },
64
+ );
48
65
 
49
66
  return {
50
- // @ts-expect-error TS2339
51
67
  render: posthtmlConfig?.contents?.render,
52
68
  evaluateRootConditionalBundles: Boolean(
53
- // @ts-expect-error TS2339
54
69
  conf?.contents?.evaluateRootConditionalBundles,
55
70
  ),
56
71
  };
57
72
  },
58
73
  async package({bundle, bundleGraph, getInlineBundleContents, config}) {
59
- // @ts-expect-error TS2552
60
74
  let assets: Array<Asset> = [];
61
75
  bundle.traverseAssets((asset) => {
62
76
  assets.push(asset);
@@ -85,13 +99,12 @@ export default new Packager({
85
99
  ),
86
100
  new Set(referencedBundles),
87
101
  )
88
- : new Set();
102
+ : new Set<NamedBundle>();
89
103
  let renderConfig = config?.render;
90
104
 
91
105
  let {html} = await posthtml([
92
106
  (tree: any) =>
93
107
  insertBundleReferences(
94
- // @ts-expect-error TS2345
95
108
  [...conditionalBundles, ...referencedBundles],
96
109
  tree,
97
110
  conditionalBundles,
@@ -131,7 +144,6 @@ async function getAssetContent(
131
144
  getInlineBundleContents: (
132
145
  arg1: Bundle,
133
146
  arg2: BundleGraph<NamedBundle>,
134
- // @ts-expect-error TS2304
135
147
  ) => Async<{
136
148
  contents: Blob;
137
149
  }>,
@@ -163,15 +175,13 @@ async function replaceInlineAssetContent(
163
175
  getInlineBundleContents: (
164
176
  arg1: Bundle,
165
177
  arg2: BundleGraph<NamedBundle>,
166
- // @ts-expect-error TS2304
167
178
  ) => Async<{
168
179
  contents: Blob;
169
180
  }>,
170
181
  tree: any,
171
182
  ) {
172
183
  const inlineNodes: Array<any> = [];
173
- // @ts-expect-error TS7006
174
- tree.walk((node) => {
184
+ tree.walk((node: any) => {
175
185
  if (node.attrs && node.attrs['data-parcel-key']) {
176
186
  inlineNodes.push(node);
177
187
  }
@@ -258,8 +268,7 @@ function insertBundleReferences(
258
268
  addBundlesToTree(bundles, tree);
259
269
  }
260
270
 
261
- // @ts-expect-error TS7006
262
- function addBundlesToTree(bundles, tree: any) {
271
+ function addBundlesToTree(bundles: any[], tree: any) {
263
272
  const main = find(tree, 'head') || find(tree, 'html');
264
273
  // @ts-expect-error TS2339
265
274
  const content = main ? main.content || (main.content = []) : tree;