Skip to content

Commit e1cea9b

Browse files
committed
fix: split parse5 type imports and fix stale .js imports
Node 24 native type stripping requires explicit `import type` for type-only parse5 imports (Document, Node, Element, Attribute, etc.). Without this, named imports fail at runtime because the types are stripped from the module's exports. Also fix remaining .js -> .ts import rewrites in multi-line from clauses that were missed by previous sed runs. Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f813e66 commit e1cea9b

16 files changed

Lines changed: 22 additions & 18 deletions

File tree

packages/dev-server-import-maps/src/importMapsPlugin.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import {
66
resolve,
77
} from '@import-maps/resolve';
88
import { getHtmlPath } from '@web/dev-server-core';
9-
import { parse as parseHtml, serialize as serializeHtml, Element as ElementAst } from 'parse5';
9+
import { parse as parseHtml, serialize as serializeHtml } from 'parse5';
10+
import type { Element as ElementAst } from 'parse5';
1011
import path from 'path';
1112

1213
import {

packages/dev-server-import-maps/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import picoMatch from 'picomatch';
22
import { Context, getHtmlPath } from '@web/dev-server-core';
3-
import { Element as ElementAst } from 'parse5';
3+
import type { Element as ElementAst } from 'parse5';
44
import { getAttribute } from '@web/parse5-utils';
55
import { ParsedImportMap } from '@import-maps/resolve';
66

packages/dev-server-legacy/src/findJsScripts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { isUri } from 'valid-url';
2-
import { Document as DocumentAst, Node as NodeAst } from 'parse5';
2+
import type { Document as DocumentAst, Node as NodeAst } from 'parse5';
33
import { queryAll, predicates, getAttribute, hasAttribute } from '@web/dev-server-core/dist/dom5';
44

55
function isDeferred(script: NodeAst) {

packages/dev-server-legacy/src/injectPolyfillsLoader.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Context } from '@web/dev-server-core';
22
import { getAttribute, getTextContent, remove } from '@web/dev-server-core/dist/dom5';
3-
import { parse, serialize, Document as DocumentAst, Node as NodeAst } from 'parse5';
3+
import { parse, serialize } from 'parse5';
4+
import type { Document as DocumentAst, Node as NodeAst } from 'parse5';
45
import {
56
injectPolyfillsLoader as originalInjectPolyfillsLoader,
67
PolyfillsConfig,

packages/dev-server-rollup/src/rollupAdapter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ import { CustomPluginOptions, Plugin as RollupPlugin, TransformPluginContext } f
2121
import { InputOptions } from 'rollup';
2222
import { red, cyan } from 'nanocolors';
2323

24-
import { toBrowserPath, isAbsoluteFilePath, isOutsideRootDir } from './utils.js';
25-
import { createRollupPluginContextAdapter } from './createRollupPluginContextAdapter.js';
26-
import { createRollupPluginContexts, RollupPluginContexts } from './createRollupPluginContexts.js';
24+
import { toBrowserPath, isAbsoluteFilePath, isOutsideRootDir } from './utils.ts';
25+
import { createRollupPluginContextAdapter } from './createRollupPluginContextAdapter.ts';
26+
import { createRollupPluginContexts, RollupPluginContexts } from './createRollupPluginContexts.ts';
2727

2828
const NULL_BYTE_PARAM = 'web-dev-server-rollup-null-byte';
2929
const VIRTUAL_FILE_PREFIX = '/__web-dev-server__/rollup';

packages/polyfills-loader/src/injectPolyfillsLoader.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Document, Node, ParentNode, parse, serialize } from 'parse5';
1+
import { parse, serialize } from 'parse5';
2+
import type { Document, Node, ParentNode } from 'parse5';
23
import {
34
findElements,
45
getAttribute,

packages/polyfills-loader/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Attribute } from 'parse5';
1+
import type { Attribute } from 'parse5';
22

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

packages/polyfills-loader/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Element } from 'parse5';
1+
import type { Element } from 'parse5';
22
import { getAttribute } from '@web/parse5-utils';
33
import crypto from 'crypto';
44
import { FileType, PolyfillsLoaderConfig } from './types.ts';

packages/rollup-plugin-html/src/assets/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Document, Element } from 'parse5';
1+
import type { Document, Element } from 'parse5';
22
import path from 'path';
33
import picomatch from 'picomatch';
44
import { findElements, getTagName, getAttribute } from '@web/parse5-utils';

packages/rollup-plugin-html/src/input/extract/extractAssets.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Document, serialize } from 'parse5';
1+
import { serialize } from 'parse5';
2+
import type { Document } from 'parse5';
23
import fs from 'fs';
34
import path from 'path';
45
import { InputAsset } from '../InputData.ts';

0 commit comments

Comments
 (0)