rolldown-require 2.0.36 → 2.1.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/dist/index.d.mts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { ExternalOption, InputOptions, OutputOptions } from "rolldown";
2
- //#region src/types.d.ts
3
2
  type RequireFunction = (outfile: string, ctx: {
4
3
  format: 'cjs' | 'esm';
5
4
  }) => any;
@@ -103,27 +102,18 @@ interface InternalOptions extends Omit<Options, 'cwd' | 'filepath'> {
103
102
  tsconfig?: string | false;
104
103
  sourcemap?: boolean | 'inline';
105
104
  }
106
- //#endregion
107
- //#region src/config.d.ts
108
105
  export declare const configDefaults: Readonly<{
109
106
  resolve: {
110
107
  extensions: string[];
111
108
  };
112
109
  }>;
113
- //#endregion
114
- //#region src/bundler.d.ts
115
110
  export declare function bundleFile(fileName: string, options: InternalOptions): Promise<{
116
111
  code: string;
117
112
  dependencies: string[];
118
113
  }>;
119
- //#endregion
120
- //#region src/loader.d.ts
121
114
  export declare function loadFromBundledFile(fileName: string, bundledCode: string, options: InternalOptions, dependencies?: string[]): Promise<any>;
122
- //#endregion
123
- //#region src/index.d.ts
124
115
  export declare function bundleRequire<T = any>(options: Options): Promise<{
125
116
  mod: T;
126
117
  dependencies: string[];
127
118
  }>;
128
- //#endregion
129
119
  export {};
package/dist/index.mjs CHANGED
@@ -12,10 +12,9 @@ import os from "node:os";
12
12
  import { promisify } from "node:util";
13
13
  import { Buffer as Buffer$1 } from "node:buffer";
14
14
  import { getTsconfig } from "get-tsconfig";
15
- //#region \0rolldown/runtime.js
15
+ // \0rolldown/runtime.js
16
16
  var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
17
- //#endregion
18
- //#region src/collect.ts
17
+ // src/collect.ts
19
18
  /**
20
19
  * 从 `fileName` 起遍历 chunk 图并收集所有引用的模块 id。
21
20
  * Rolldown 在 `inlineDynamicImports` 为 true 时会内联动态导入,
@@ -30,15 +29,13 @@ function collectReferencedModules(bundle, fileName, allModules, analyzedModules
30
29
  for (const imported of chunk.imports) collectReferencedModules(bundle, imported, allModules, analyzedModules);
31
30
  for (const imported of chunk.dynamicImports) collectReferencedModules(bundle, imported, allModules, analyzedModules);
32
31
  }
33
- //#endregion
34
- //#region src/sharedUtils.ts
32
+ // src/sharedUtils.ts
35
33
  const isWindows = typeof process !== "undefined" && process.platform === "win32";
36
34
  const windowsSlashRE = /\\/g;
37
35
  function slash(p) {
38
36
  return p.replace(windowsSlashRE, "/");
39
37
  }
40
- //#endregion
41
- //#region src/constants.ts
38
+ // src/constants.ts
42
39
  const BOM_RE = /^\uFEFF/;
43
40
  function stripBom(value) {
44
41
  return value.replace(BOM_RE, "");
@@ -151,8 +148,7 @@ function traverseBetweenDirs(longerDir, shorterDir, cb) {
151
148
  longerDir = path.dirname(longerDir);
152
149
  }
153
150
  }
154
- //#endregion
155
- //#region src/utils.ts
151
+ // src/utils.ts
156
152
  const MJS_MTS_EXT_RE = /\.m[jt]s$/;
157
153
  const CJS_CTS_EXT_RE = /\.c[jt]s$/;
158
154
  const createFilter$1 = createFilter;
@@ -256,8 +252,7 @@ function stripBomTag(content) {
256
252
  const dynamicImport = async (id, { format }) => {
257
253
  return (format === "esm" ? (file) => import(file) : TSUP_FORMAT === "esm" ? createRequire(import.meta.url) : __require)(id);
258
254
  };
259
- //#endregion
260
- //#region src/externalize.ts
255
+ // src/externalize.ts
261
256
  const NON_RELATIVE_NON_HASH_RE = /^[^.#].*/;
262
257
  function createExternalizeDepsPlugin({ entryFile, isESM }) {
263
258
  const entryDir = path.dirname(entryFile);
@@ -408,8 +403,7 @@ function resolveSpecifierFromImporter(specifier, importerPath) {
408
403
  return;
409
404
  }
410
405
  }
411
- //#endregion
412
- //#region src/module-sync.ts
406
+ // src/module-sync.ts
413
407
  let cachedModuleSyncCondition;
414
408
  let moduleSyncConditionPromise;
415
409
  async function getModuleSyncConditionEnabled() {
@@ -422,8 +416,7 @@ async function getModuleSyncConditionEnabled() {
422
416
  });
423
417
  return moduleSyncConditionPromise;
424
418
  }
425
- //#endregion
426
- //#region src/bundler.ts
419
+ // src/bundler.ts
427
420
  const JS_TS_EXT_RE = /\.[cm]?[jt]s$/;
428
421
  async function bundleFile(fileName, options) {
429
422
  const { isESM } = options;
@@ -549,8 +542,7 @@ function createFileScopeVariablesPlugin({ dirnameVarName, filenameVarName, impor
549
542
  }
550
543
  };
551
544
  }
552
- //#endregion
553
- //#region src/cache.ts
545
+ // src/cache.ts
554
546
  const _require$1 = createRequire(import.meta.url);
555
547
  const memoryCache = /* @__PURE__ */ new Map();
556
548
  function resolveCacheOptions(fileName, options) {
@@ -745,8 +737,7 @@ function hashEntrySource(source) {
745
737
  if (source === void 0) return "none";
746
738
  return crypto.createHash("sha1").update(source).digest("hex");
747
739
  }
748
- //#endregion
749
- //#region src/config.ts
740
+ // src/config.ts
750
741
  const configDefaults = Object.freeze({ resolve: { extensions: [
751
742
  ".mjs",
752
743
  ".js",
@@ -759,8 +750,7 @@ const configDefaults = Object.freeze({ resolve: { extensions: [
759
750
  const defaultGetOutputFile = (filepath, _format) => {
760
751
  return filepath;
761
752
  };
762
- //#endregion
763
- //#region src/temp-output.ts
753
+ // src/temp-output.ts
764
754
  const NON_WORD_CHAR_RE = /[^\w.-]/g;
765
755
  function sanitizeFilename(name) {
766
756
  return name.replace(NON_WORD_CHAR_RE, "_");
@@ -797,8 +787,7 @@ async function resolveTempOutputFile(sourceFile, code, options) {
797
787
  };
798
788
  throw new Error("Failed to create temporary output file for bundled code");
799
789
  }
800
- //#endregion
801
- //#region src/loader.ts
790
+ // src/loader.ts
802
791
  const _require = createRequire(import.meta.url);
803
792
  const promisifiedRealpath = promisify(fs.realpath);
804
793
  async function loadFromBundledFile(fileName, bundledCode, options, dependencies) {
@@ -868,8 +857,7 @@ async function loadFromBundledFile(fileName, bundledCode, options, dependencies)
868
857
  }
869
858
  }
870
859
  }
871
- //#endregion
872
- //#region src/options.ts
860
+ // src/options.ts
873
861
  function resolveEntryFilepath(options) {
874
862
  if (path.isAbsolute(options.filepath)) return options.filepath;
875
863
  const cwd = options.cwd ? path.resolve(options.cwd) : process.cwd();
@@ -906,8 +894,7 @@ function shouldEnableSourcemapFromEnv() {
906
894
  if (process.env.DEBUG) return true;
907
895
  return false;
908
896
  }
909
- //#endregion
910
- //#region src/index.ts
897
+ // src/index.ts
911
898
  async function bundleRequire(options) {
912
899
  const resolvedPath = resolveEntryFilepath(options);
913
900
  const internalOptions = createInternalOptions(options, detectModuleType(resolvedPath));
@@ -929,5 +916,4 @@ async function bundleRequire(options) {
929
916
  dependencies: bundled.dependencies
930
917
  };
931
918
  }
932
- //#endregion
933
919
  export { bundleFile, bundleRequire, configDefaults, loadFromBundledFile };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rolldown-require",
3
3
  "type": "module",
4
- "version": "2.0.36",
4
+ "version": "2.1.0",
5
5
  "description": "bundle and require a file using rolldown!",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -50,17 +50,17 @@
50
50
  "misc"
51
51
  ],
52
52
  "engines": {
53
- "node": "^20.19.0 || >=22.12.0"
53
+ "node": "^22.23.4 || ^24.22.1 || >=26.12.1"
54
54
  },
55
55
  "publishConfig": {
56
56
  "access": "public",
57
57
  "registry": "https://registry.npmjs.org"
58
58
  },
59
59
  "peerDependencies": {
60
- "rolldown": "1.2.14"
60
+ "rolldown": "1.2.15"
61
61
  },
62
62
  "dependencies": {
63
- "@rollup/pluginutils": "^5.4.0",
63
+ "@rollup/pluginutils": "^5.5.1",
64
64
  "get-tsconfig": "^4.14.3"
65
65
  },
66
66
  "devDependencies": {