rolldown-require 2.0.20 → 2.0.22
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/dist/index.mjs +12 -11
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3,8 +3,8 @@ import path from "node:path";
|
|
|
3
3
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
4
|
import { rolldown } from "rolldown";
|
|
5
5
|
import fs, { readFileSync } from "node:fs";
|
|
6
|
-
import { exec } from "node:child_process";
|
|
7
6
|
import process from "node:process";
|
|
7
|
+
import { exec } from "node:child_process";
|
|
8
8
|
import { createFilter } from "@rollup/pluginutils";
|
|
9
9
|
import crypto from "node:crypto";
|
|
10
10
|
import fsp from "node:fs/promises";
|
|
@@ -31,6 +31,13 @@ function collectReferencedModules(bundle, fileName, allModules, analyzedModules
|
|
|
31
31
|
for (const imported of chunk.dynamicImports) collectReferencedModules(bundle, imported, allModules, analyzedModules);
|
|
32
32
|
}
|
|
33
33
|
//#endregion
|
|
34
|
+
//#region src/sharedUtils.ts
|
|
35
|
+
const isWindows = typeof process !== "undefined" && process.platform === "win32";
|
|
36
|
+
const windowsSlashRE = /\\/g;
|
|
37
|
+
function slash(p) {
|
|
38
|
+
return p.replace(windowsSlashRE, "/");
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
34
41
|
//#region src/constants.ts
|
|
35
42
|
const BOM_RE = /^\uFEFF/;
|
|
36
43
|
function stripBom(value) {
|
|
@@ -141,13 +148,6 @@ function traverseBetweenDirs(longerDir, shorterDir, cb) {
|
|
|
141
148
|
}
|
|
142
149
|
}
|
|
143
150
|
//#endregion
|
|
144
|
-
//#region src/sharedUtils.ts
|
|
145
|
-
const isWindows = typeof process !== "undefined" && process.platform === "win32";
|
|
146
|
-
const windowsSlashRE = /\\/g;
|
|
147
|
-
function slash(p) {
|
|
148
|
-
return p.replace(windowsSlashRE, "/");
|
|
149
|
-
}
|
|
150
|
-
//#endregion
|
|
151
151
|
//#region src/utils.ts
|
|
152
152
|
const MJS_MTS_EXT_RE = /\.m[jt]s$/;
|
|
153
153
|
const CJS_CTS_EXT_RE = /\.c[jt]s$/;
|
|
@@ -304,10 +304,8 @@ function createExternalizeDepsPlugin({ entryFile, isESM }) {
|
|
|
304
304
|
return idWithQuery;
|
|
305
305
|
}
|
|
306
306
|
const shouldExternalize = shouldExternalizeBareImport(id, importer, entryDir, resolvedPath, entryResolveCache);
|
|
307
|
-
let idOut = resolvedPath + query;
|
|
308
|
-
if (isImport && shouldExternalize) idOut = pathToFileURL(resolvedPath).href + query;
|
|
309
307
|
const result = {
|
|
310
|
-
id:
|
|
308
|
+
id: formatExternalizedFileId(resolvedPath, query, isImport && shouldExternalize),
|
|
311
309
|
external: shouldExternalize
|
|
312
310
|
};
|
|
313
311
|
externalizeCache.set(cacheKey, result);
|
|
@@ -316,6 +314,9 @@ function createExternalizeDepsPlugin({ entryFile, isESM }) {
|
|
|
316
314
|
}
|
|
317
315
|
};
|
|
318
316
|
}
|
|
317
|
+
function formatExternalizedFileId(resolvedPath, query, asFileUrl) {
|
|
318
|
+
return asFileUrl ? pathToFileURL(resolvedPath).href + query : slash(resolvedPath) + query;
|
|
319
|
+
}
|
|
319
320
|
function shouldExternalizeBareImport(specifier, importer, entryDir, resolvedPath, canResolveCache) {
|
|
320
321
|
if (!specifier || specifier.startsWith(".") || path.isAbsolute(specifier)) return false;
|
|
321
322
|
if (isNodeLikeBuiltin(specifier)) return true;
|