Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nodelss): use valid esm inject paths #369

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/presets/nodeless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ const nodeless: Preset & { alias: Map<string, string> } = {

inject: {
global: "unenv/runtime/node/_global",
process: "unenv/runtime/node/process",
Buffer: ["buffer", "Buffer"],
process: "unenv/runtime/node/process/index",
Buffer: ["unenv/runtime/node/buffer/index", "Buffer"],
performance: "unenv/runtime/polyfill/performance",
},

Expand Down
12 changes: 6 additions & 6 deletions test/workerd/tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ globalThis.process = process;

export const crypto_getRandomValues = {
async test() {
const crypto = await import("unenv/runtime/node/crypto");
const crypto = await import("unenv/runtime/node/crypto/index");

const array = new Uint32Array(10);
crypto.getRandomValues(array);
Expand All @@ -21,7 +21,7 @@ export const crypto_getRandomValues = {

export const url_parse = {
async test() {
const url = await import("unenv/runtime/node/url");
const url = await import("unenv/runtime/node/url/index");

assert.throws(
() => {
Expand All @@ -36,7 +36,7 @@ export const url_parse = {

export const unenv_polyfills_buffer = {
async test() {
const buffer = await import("unenv/runtime/node/buffer");
const buffer = await import("unenv/runtime/node/buffer/index");
const Buffer = buffer.Buffer;
assert.strictEqual(typeof buffer.isAscii, "function");
assert.strictEqual(typeof buffer.isUtf8, "function");
Expand Down Expand Up @@ -97,7 +97,7 @@ export const workerd_modules = {

export const util_implements = {
async test() {
const { types } = await import("unenv/runtime/node/util");
const { types } = await import("unenv/runtime/node/util/index");
assert.strictEqual(types.isExternal("hello world"), false);
assert.strictEqual(types.isAnyArrayBuffer(new ArrayBuffer(0)), true);
},
Expand All @@ -107,13 +107,13 @@ export const util_implements = {

export const unenv_polyfills_path = {
async test() {
const pathWin32 = await import("unenv/runtime/node/path/win32");
const pathWin32 = await import("unenv/runtime/node/path/win32/index");
assert.strictEqual(typeof pathWin32.resolve, "function");
// Note: unenv uses `unjs/pathe` which behavior differs from Node.js
// See https://github.com/unjs/pathe
assert.strictEqual(pathWin32.sep, "/");
assert.strictEqual(pathWin32.delimiter, ":");
const pathPosix = await import("unenv/runtime/node/path/posix");
const pathPosix = await import("unenv/runtime/node/path/posix/index");
assert.strictEqual(typeof pathPosix.resolve, "function");
},
};
Expand Down