@jsenv/plugin-commonjs 2.9.0 → 2.9.1

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.9.0",
3
+ "version": "2.9.1",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,10 +21,10 @@
21
21
  "/src/"
22
22
  ],
23
23
  "dependencies": {
24
- "@jsenv/filesystem": "4.10.11",
24
+ "@jsenv/filesystem": "4.10.12",
25
25
  "@jsenv/humanize": "1.2.8",
26
26
  "@jsenv/url-meta": "8.5.2",
27
- "@jsenv/urls": "2.5.2",
27
+ "@jsenv/urls": "2.5.3",
28
28
  "@rollup/plugin-commonjs": "28.0.1",
29
29
  "@rollup/plugin-json": "6.1.0",
30
30
  "@rollup/plugin-node-resolve": "15.3.0",
@@ -1,6 +1,5 @@
1
1
  import { createLogger } from "@jsenv/humanize";
2
- import { fileURLToPath } from "node:url";
3
-
2
+ import { urlToFileSystemPath } from "@jsenv/urls";
4
3
  import { rollupPluginCommonJsNamedExports } from "./rollup_plugin_commonjs_named_exports.js";
5
4
 
6
5
  export const commonJsToJsModuleRaw = async ({
@@ -28,7 +27,7 @@ export const commonJsToJsModuleRaw = async ({
28
27
  `compatible only with file:// protocol, got ${sourceFileUrl}`,
29
28
  );
30
29
  }
31
- const sourceFilePath = fileURLToPath(sourceFileUrl);
30
+ const sourceFilePath = urlToFileSystemPath(sourceFileUrl);
32
31
 
33
32
  const { nodeResolve } = await import("@rollup/plugin-node-resolve");
34
33
  const nodeResolveRollupPlugin = nodeResolve({
@@ -160,7 +159,7 @@ export const commonJsToJsModuleRaw = async ({
160
159
  sourcemap: true,
161
160
  sourcemapExcludeSources,
162
161
  exports: "named",
163
- dir: fileURLToPath(abstractDirUrl),
162
+ dir: urlToFileSystemPath(abstractDirUrl),
164
163
  sourcemapPathTransform: (relativePath) => {
165
164
  const sourceUrl = new URL(relativePath, abstractDirUrl).href;
166
165
  return sourceUrl;
@@ -1,7 +1,6 @@
1
1
  import { bufferToEtag, writeFileSync } from "@jsenv/filesystem";
2
- import { urlToRelativeUrl } from "@jsenv/urls";
2
+ import { urlToFileSystemPath, urlToRelativeUrl } from "@jsenv/urls";
3
3
  import { existsSync, utimesSync } from "node:fs";
4
- import { fileURLToPath } from "node:url";
5
4
 
6
5
  export const updateCompileCache = ({
7
6
  logger,
@@ -38,7 +37,9 @@ cache will be reused even if one of the source file is modified
38
37
  ${filesRemoved.join(`\n`)}`);
39
38
  }
40
39
 
41
- logger.debug(`write compiled file at ${fileURLToPath(compiledFileUrl)}`);
40
+ logger.debug(
41
+ `write compiled file at ${urlToFileSystemPath(compiledFileUrl)}`,
42
+ );
42
43
  writeFileSync(compiledFileUrl, content, {
43
44
  fileLikelyNotFound: isNew,
44
45
  });
@@ -50,7 +51,9 @@ ${filesRemoved.join(`\n`)}`);
50
51
 
51
52
  const assetInfos = {};
52
53
  Object.keys(assets).forEach((assetUrl) => {
53
- logger.debug(`write compiled file asset at ${fileURLToPath(assetUrl)}`);
54
+ logger.debug(
55
+ `write compiled file asset at ${urlToFileSystemPath(assetUrl)}`,
56
+ );
54
57
  const asset = assets[assetUrl];
55
58
  writeFileSync(assetUrl, asset.content, {
56
59
  fileLikelyNotFound: isNew,
@@ -82,7 +85,7 @@ ${filesRemoved.join(`\n`)}`);
82
85
  };
83
86
  }
84
87
  logger.debug(
85
- `write compiled file info at ${fileURLToPath(compileInfoFileUrl)}`,
88
+ `write compiled file info at ${urlToFileSystemPath(compileInfoFileUrl)}`,
86
89
  );
87
90
  writeFileSync(
88
91
  compileInfoFileUrl,
@@ -1,5 +1,5 @@
1
- import { bufferToEtag } from "@jsenv/filesystem";
2
- import { readFileSync, statSync } from "node:fs";
1
+ import { bufferToEtag, readEntryStatSync } from "@jsenv/filesystem";
2
+ import { readFileSync } from "node:fs";
3
3
 
4
4
  export const validateCompileCache = ({
5
5
  compiledFileUrl,
@@ -94,7 +94,7 @@ const validateCompiledFile = ({
94
94
  }
95
95
  }
96
96
  if (compileCacheStrategy === "mtime" && lastModificationTime) {
97
- const stats = statSync(new URL(compiledFileUrl));
97
+ const stats = readEntryStatSync(new URL(compiledFileUrl));
98
98
  const mtime = Math.floor(stats.mtimeMs);
99
99
  validity.data.mtime = mtime;
100
100
  let ifModifiedSinceDate;
@@ -1,10 +1,11 @@
1
1
  // https://github.com/snowpackjs/snowpack/blob/main/esinstall/src/rollup-plugins/rollup-plugin-wrap-install-targets.ts
2
2
 
3
+ import { urlToFileSystemPath } from "@jsenv/urls";
3
4
  import { init, parse } from "cjs-module-lexer";
4
5
  import isValidIdentifier from "is-valid-identifier";
5
6
  import { readFileSync } from "node:fs";
6
7
  import path from "node:path";
7
- import { fileURLToPath, pathToFileURL } from "node:url";
8
+ import { pathToFileURL } from "node:url";
8
9
  import { Worker } from "node:worker_threads";
9
10
  import resolve from "resolve";
10
11
 
@@ -101,7 +102,7 @@ const detectStaticExports = ({ logger, filePath, visited = new Set() }) => {
101
102
  if (reexports.length > 0) {
102
103
  reexports.forEach((reexport) => {
103
104
  const reExportedFilePath = resolve.sync(reexport, {
104
- basedir: fileURLToPath(new URL("./", pathToFileURL(filePath))),
105
+ basedir: urlToFileSystemPath(new URL("./", pathToFileURL(filePath))),
105
106
  });
106
107
  const staticExports = detectStaticExports({
107
108
  logger,