@jsenv/plugin-commonjs 2.1.1 → 2.2.0

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.1.1",
3
+ "version": "2.2.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -24,18 +24,18 @@
24
24
  "test": "node --conditions=development ./scripts/test.mjs"
25
25
  },
26
26
  "dependencies": {
27
- "@jsenv/filesystem": "4.2.3",
27
+ "@jsenv/filesystem": "4.2.4",
28
28
  "@jsenv/log": "3.4.0",
29
29
  "@jsenv/url-meta": "8.1.0",
30
- "@jsenv/urls": "2.0.0",
31
- "@rollup/plugin-commonjs": "25.0.0",
30
+ "@jsenv/urls": "2.1.0",
31
+ "@rollup/plugin-commonjs": "25.0.2",
32
32
  "@rollup/plugin-json": "6.0.0",
33
33
  "@rollup/plugin-node-resolve": "15.1.0",
34
34
  "@rollup/plugin-replace": "5.0.2",
35
- "cjs-module-lexer": "1.2.2",
35
+ "cjs-module-lexer": "1.2.3",
36
36
  "is-valid-identifier": "2.0.2",
37
37
  "resolve": "1.22.2",
38
- "rollup": "3.24.0",
38
+ "rollup": "3.26.2",
39
39
  "rollup-plugin-node-globals": "1.4.0",
40
40
  "rollup-plugin-polyfill-node": "0.12.0",
41
41
  "vm2": "3.9.19"
@@ -16,7 +16,7 @@ export const jsenvPluginCommonJs = ({
16
16
  const packageFileUrl = defaultLookupPackageScope(reference.url);
17
17
  if (packageFileUrl) {
18
18
  reference.filename = `${reference.specifier}${urlToExtension(
19
- reference.parentUrl,
19
+ reference.ownerUrlInfo.url,
20
20
  )}`;
21
21
  }
22
22
  };
@@ -56,31 +56,28 @@ export const jsenvPluginCommonJs = ({
56
56
  reference.data.commonjs = commonjs;
57
57
  return turnIntoJsModuleProxy(reference);
58
58
  },
59
- fetchUrlContent: async (urlInfo, context) => {
60
- const [commonJsReference, commonJsUrlInfo] =
61
- context.getWithoutSearchParam({
62
- urlInfo,
63
- context,
64
- searchParam: "cjs_as_js_module",
59
+ fetchUrlContent: async (urlInfo) => {
60
+ const commonJsUrlInfo = urlInfo.getWithoutSearchParam(
61
+ "cjs_as_js_module",
62
+ {
65
63
  // during this fetch we don't want to alter the original file
66
64
  // so we consider it as text
67
65
  expectedType: "text",
68
- });
69
- if (!commonJsReference) {
66
+ },
67
+ );
68
+ if (!commonJsUrlInfo) {
70
69
  return null;
71
70
  }
72
- await context.fetchUrlContent(commonJsUrlInfo, {
73
- reference: commonJsReference,
74
- });
75
- const nodeRuntimeEnabled = Object.keys(context.runtimeCompat).includes(
76
- "node",
77
- );
71
+ await commonJsUrlInfo.fetchContent();
72
+ const nodeRuntimeEnabled = Object.keys(
73
+ urlInfo.context.runtimeCompat,
74
+ ).includes("node");
78
75
  const { content, sourcemap, isValid } = await commonJsToJsModule({
79
76
  logLevel,
80
77
  compileCacheDirectoryUrl,
81
78
  sourceFileUrl: commonJsUrlInfo.url,
82
79
  browsers: !nodeRuntimeEnabled,
83
- processEnvNodeEnv: context.dev ? "development" : "production",
80
+ processEnvNodeEnv: urlInfo.context.dev ? "development" : "production",
84
81
  ...urlInfo.data.commonjs,
85
82
  });
86
83
  if (isValid) {