Skip to content

Commit dff9b8c

Browse files
committed
fix: update polyfills-loader parse5 types for v8
Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 84ce40b commit dff9b8c

3 files changed

Lines changed: 15 additions & 9 deletions

File tree

packages/polyfills-loader/src/injectPolyfillsLoader.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { Document, Node, ParentNode, parse, serialize } from 'parse5';
1+
import type { DefaultTreeAdapterTypes } from 'parse5';
2+
type Document = DefaultTreeAdapterTypes.Document;
3+
type Node = DefaultTreeAdapterTypes.Node;
4+
type ParentNode = DefaultTreeAdapterTypes.ParentNode;
5+
import { parse, serialize } from 'parse5';
26
import {
37
findElements,
48
getAttribute,
@@ -9,16 +13,16 @@ import {
913
createElement,
1014
findElement,
1115
getTagName,
12-
Element,
1316
} from '@web/parse5-utils';
17+
import type { Element } from '@web/parse5-utils';
1418

15-
import { PolyfillsLoaderConfig, PolyfillsLoader, GeneratedFile } from './types.js';
16-
import { createPolyfillsLoader } from './createPolyfillsLoader.js';
17-
import { hasFileOfType, fileTypes } from './utils.js';
19+
import type { PolyfillsLoaderConfig, PolyfillsLoader, GeneratedFile } from './types.ts';
20+
import { createPolyfillsLoader } from './createPolyfillsLoader.ts';
21+
import { hasFileOfType, fileTypes } from './utils.ts';
1822

1923
function injectImportMapPolyfill(headAst: ParentNode, originalScript: Node, type: string) {
2024
const systemJsScript = createScript({ type }, getTextContent(originalScript));
21-
insertBefore(headAst, systemJsScript, originalScript);
25+
insertBefore(headAst, systemJsScript, originalScript as any);
2226
}
2327

2428
function findImportMapScripts(document: Document) {

packages/polyfills-loader/src/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import type { Attribute } from 'parse5';
1+
import type { Token } from 'parse5';
2+
type Attribute = Token.Attribute;
23

34
export interface PolyfillsLoaderConfig {
45
// files to load on modern browsers. loaded when there are no

packages/polyfills-loader/src/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { Element } from 'parse5';
1+
import type { DefaultTreeAdapterTypes } from 'parse5';
2+
type Element = DefaultTreeAdapterTypes.Element;
23
import { getAttribute } from '@web/parse5-utils';
34
import crypto from 'crypto';
4-
import { FileType, PolyfillsLoaderConfig } from './types.js';
5+
import type { FileType, PolyfillsLoaderConfig } from './types.ts';
56

67
export const noModuleSupportTest = "!('noModule' in HTMLScriptElement.prototype)";
78

0 commit comments

Comments
 (0)