rolldown-require 2.0.21 → 2.0.23

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.
Files changed (2) hide show
  1. package/dist/index.mjs +19 -15
  2. package/package.json +3 -3
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) {
@@ -66,10 +73,13 @@ function loadPackageData(pkgPath) {
66
73
  let hasSideEffects;
67
74
  if (typeof sideEffects === "boolean") hasSideEffects = () => sideEffects;
68
75
  else if (Array.isArray(sideEffects)) if (sideEffects.length <= 0) hasSideEffects = () => false;
69
- else hasSideEffects = createFilter$1(sideEffects.map((sideEffect) => {
70
- if (sideEffect.includes("/")) return sideEffect;
71
- return `**/${sideEffect}`;
72
- }), null, { resolve: pkgDir });
76
+ else {
77
+ const finalPackageSideEffects = sideEffects.map((sideEffect) => {
78
+ if (sideEffect.includes("/")) return sideEffect;
79
+ return `**/${sideEffect}`;
80
+ });
81
+ hasSideEffects = createFilter$1(finalPackageSideEffects, null, { resolve: pkgDir });
82
+ }
73
83
  else hasSideEffects = () => null;
74
84
  const resolvedCache = {};
75
85
  return {
@@ -141,13 +151,6 @@ function traverseBetweenDirs(longerDir, shorterDir, cb) {
141
151
  }
142
152
  }
143
153
  //#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
154
  //#region src/utils.ts
152
155
  const MJS_MTS_EXT_RE = /\.m[jt]s$/;
153
156
  const CJS_CTS_EXT_RE = /\.c[jt]s$/;
@@ -304,10 +307,8 @@ function createExternalizeDepsPlugin({ entryFile, isESM }) {
304
307
  return idWithQuery;
305
308
  }
306
309
  const shouldExternalize = shouldExternalizeBareImport(id, importer, entryDir, resolvedPath, entryResolveCache);
307
- let idOut = resolvedPath + query;
308
- if (isImport && shouldExternalize) idOut = pathToFileURL(resolvedPath).href + query;
309
310
  const result = {
310
- id: idOut,
311
+ id: formatExternalizedFileId(resolvedPath, query, isImport && shouldExternalize),
311
312
  external: shouldExternalize
312
313
  };
313
314
  externalizeCache.set(cacheKey, result);
@@ -316,6 +317,9 @@ function createExternalizeDepsPlugin({ entryFile, isESM }) {
316
317
  }
317
318
  };
318
319
  }
320
+ function formatExternalizedFileId(resolvedPath, query, asFileUrl) {
321
+ return asFileUrl ? pathToFileURL(resolvedPath).href + query : slash(resolvedPath) + query;
322
+ }
319
323
  function shouldExternalizeBareImport(specifier, importer, entryDir, resolvedPath, canResolveCache) {
320
324
  if (!specifier || specifier.startsWith(".") || path.isAbsolute(specifier)) return false;
321
325
  if (isNodeLikeBuiltin(specifier)) return true;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rolldown-require",
3
3
  "type": "module",
4
- "version": "2.0.21",
4
+ "version": "2.0.23",
5
5
  "description": "bundle and require a file using rolldown!",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -48,11 +48,11 @@
48
48
  "node": "^20.19.0 || >=22.12.0"
49
49
  },
50
50
  "peerDependencies": {
51
- "rolldown": "1.1.5"
51
+ "rolldown": "1.2.2"
52
52
  },
53
53
  "dependencies": {
54
54
  "@rollup/pluginutils": "^5.4.0",
55
- "get-tsconfig": "^4.14.0"
55
+ "get-tsconfig": "^4.14.1"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/pnpapi": "^0.0.5"