fix(vite): importing node:* builtins (#3245)
This commit is contained in:
@@ -75,6 +75,7 @@
|
||||
"npm:esbuild-wasm@0.25.7": "0.25.7",
|
||||
"npm:esbuild@0.25.7": "0.25.7",
|
||||
"npm:esbuild@~0.25.5": "0.25.7",
|
||||
"npm:feed@^5.1.0": "5.1.0",
|
||||
"npm:fflate@~0.8.2": "0.8.2",
|
||||
"npm:github-slugger@2": "2.0.0",
|
||||
"npm:linkedom@~0.18.10": "0.18.12",
|
||||
@@ -94,6 +95,7 @@
|
||||
"npm:ts-morph@26": "26.0.0",
|
||||
"npm:vite-plugin-inspect@^11.3.2": "11.3.2_vite@7.1.3__@types+node@24.3.0__picomatch@4.0.3_@types+node@24.3.0",
|
||||
"npm:vite@*": "7.1.3_@types+node@24.3.0_picomatch@4.0.3",
|
||||
"npm:vite@7.1.3": "7.1.3_@types+node@24.3.0_picomatch@4.0.3",
|
||||
"npm:vite@^7.1.3": "7.1.3_@types+node@24.3.0_picomatch@4.0.3"
|
||||
},
|
||||
"jsr": {
|
||||
@@ -1846,6 +1848,12 @@
|
||||
"picomatch@4.0.3"
|
||||
]
|
||||
},
|
||||
"feed@5.1.0": {
|
||||
"integrity": "sha512-qGNhgYygnefSkAHHrNHqC7p3R8J0/xQDS/cYUud8er/qD9EFGWyCdUDfULHTJQN1d3H3WprzVwMc9MfB4J50Wg==",
|
||||
"dependencies": [
|
||||
"xml-js"
|
||||
]
|
||||
},
|
||||
"fflate@0.8.2": {
|
||||
"integrity": "sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A=="
|
||||
},
|
||||
@@ -2614,6 +2622,9 @@
|
||||
"queue-microtask"
|
||||
]
|
||||
},
|
||||
"sax@1.4.1": {
|
||||
"integrity": "sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg=="
|
||||
},
|
||||
"semver@6.3.1": {
|
||||
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
|
||||
"bin": true
|
||||
@@ -2897,6 +2908,13 @@
|
||||
"is-wsl@3.1.0"
|
||||
]
|
||||
},
|
||||
"xml-js@1.6.11": {
|
||||
"integrity": "sha512-7rVi2KMfwfWFl+GpPg6m80IVMWXLRjO+PxTq7V2CDhoGak0wzYzFgUY2m4XJ47OGdXd8eLE8EmwfAmdjw7lC1g==",
|
||||
"dependencies": [
|
||||
"sax"
|
||||
],
|
||||
"bin": true
|
||||
},
|
||||
"y18n@5.0.8": {
|
||||
"integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA=="
|
||||
},
|
||||
@@ -3059,6 +3077,7 @@
|
||||
"npm:@tailwindcss/vite@^4.1.12",
|
||||
"npm:@types/babel__core@^7.20.5",
|
||||
"npm:@types/node@^24.1.0",
|
||||
"npm:feed@^5.1.0",
|
||||
"npm:mime-db@^1.54.0",
|
||||
"npm:preact@^10.26.9",
|
||||
"npm:rollup-plugin-visualizer@^6.0.3",
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import * as feed from "feed";
|
||||
|
||||
export default function Page() {
|
||||
// deno-lint-ignore no-console
|
||||
console.log(feed);
|
||||
return <h1>feed</h1>;
|
||||
}
|
||||
@@ -27,6 +27,7 @@
|
||||
"@tailwindcss/vite": "npm:@tailwindcss/vite@^4.1.12",
|
||||
"@types/babel__core": "npm:@types/babel__core@^7.20.5",
|
||||
"@types/node": "npm:@types/node@^24.1.0",
|
||||
"feed": "npm:feed@^5.1.0",
|
||||
"mime-db": "npm:mime-db@^1.54.0",
|
||||
"preact": "npm:preact@^10.26.9",
|
||||
"rollup-plugin-visualizer": "npm:rollup-plugin-visualizer@^6.0.3",
|
||||
|
||||
@@ -102,6 +102,13 @@ export function deno(): Plugin {
|
||||
ResolutionMode.Import,
|
||||
);
|
||||
|
||||
if (resolved.startsWith("node:")) {
|
||||
return {
|
||||
id: resolved,
|
||||
external: true,
|
||||
};
|
||||
}
|
||||
|
||||
if (original === resolved) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -322,3 +322,21 @@ Deno.test({
|
||||
sanitizeOps: false,
|
||||
sanitizeResources: false,
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "vite build - import node:*",
|
||||
fn: async () => {
|
||||
await using res = await buildVite(DEMO_DIR);
|
||||
|
||||
await launchProd(
|
||||
{ cwd: res.tmp },
|
||||
async (address) => {
|
||||
const res = await fetch(`${address}/tests/feed`);
|
||||
await res.body?.cancel();
|
||||
expect(res.status).toEqual(200);
|
||||
},
|
||||
);
|
||||
},
|
||||
sanitizeOps: false,
|
||||
sanitizeResources: false,
|
||||
});
|
||||
|
||||
@@ -251,3 +251,16 @@ Deno.test({
|
||||
sanitizeResources: false,
|
||||
sanitizeOps: false,
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "vite dev - import node:*",
|
||||
fn: async () => {
|
||||
await withDevServer(DEMO_DIR, async (address) => {
|
||||
const res = await fetch(`${address}/tests/feed`);
|
||||
await res.body?.cancel();
|
||||
expect(res.status).toEqual(200);
|
||||
});
|
||||
},
|
||||
sanitizeResources: false,
|
||||
sanitizeOps: false,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user