@jsenv/plugin-commonjs 2.11.18 → 2.11.20

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/plugin-commonjs",
3
- "version": "2.11.18",
3
+ "version": "2.11.20",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,16 +27,16 @@
27
27
  "@rollup/plugin-json": "6.1.0",
28
28
  "@rollup/plugin-node-resolve": "16.0.3",
29
29
  "@rollup/plugin-replace": "6.0.3",
30
- "cjs-module-lexer": "2.2.0",
30
+ "cjs-module-lexer": "2.2.1",
31
31
  "is-valid-identifier": "2.0.2",
32
32
  "resolve": "1.22.12",
33
- "rollup": "4.62.2",
33
+ "rollup": "4.62.4",
34
34
  "rollup-plugin-polyfill-node": "0.13.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@jsenv/assert": "../tooling/assert",
38
38
  "@jsenv/core": "../../",
39
- "playwright": "1.61.1"
39
+ "playwright": "1.62.1"
40
40
  },
41
41
  "publishConfig": {
42
42
  "access": "public"
@@ -1,5 +1,6 @@
1
1
  import { createLogger } from "@jsenv/humanize";
2
2
  import { urlToFileSystemPath } from "@jsenv/urls";
3
+ import { isBuiltin } from "node:module";
3
4
  import { rollupPluginCommonJsNamedExports } from "./rollup_plugin_commonjs_named_exports.js";
4
5
 
5
6
  export const commonJsToJsModuleRaw = async ({
@@ -92,6 +93,16 @@ export const commonJsToJsModuleRaw = async ({
92
93
  if (specifier.startsWith("node:")) {
93
94
  return { id: specifier, external: true };
94
95
  }
96
+ // Keep node builtins external when targeting node. A bare builtin
97
+ // (e.g. `require("util")` inside ws) must NOT be resolved into a
98
+ // userland package of the same name (a `util` polyfill hoisted into
99
+ // node_modules) — Node resolves the builtin, and that polyfill lacks
100
+ // Node-only APIs like util.types, so bundling it breaks at runtime.
101
+ // When converting builtins to browser equivalents this must stay off,
102
+ // so the polyfill plugin can do its job.
103
+ if (!convertBuiltinsToBrowser && isBuiltin(specifier)) {
104
+ return { id: `node:${specifier}`, external: true };
105
+ }
95
106
  return null;
96
107
  },
97
108
  },