rolldown-require 2.0.6 → 2.0.7

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/README.md CHANGED
@@ -123,7 +123,7 @@ The library is under active development. If you encounter any issues or have sug
123
123
 
124
124
  `pnpm --filter rolldown-require-bench benchmark` (10 cold iterations, local M3, Node 22.21.1):
125
125
 
126
- ```
126
+ ```text
127
127
  Scenario: tiny-static (25 modules)
128
128
  rolldown-require | avg 60.52ms | median 58.36ms | deps 26 | rssΔ median 1.02 MB
129
129
  unrun | avg 61.16ms | median 61.32ms | deps 26 | rssΔ median 0.64 MB
package/dist/index.mjs CHANGED
@@ -180,6 +180,8 @@ function slash(p) {
180
180
  }
181
181
 
182
182
  // src/utils.ts
183
+ var MJS_MTS_EXT_RE = /\.m[jt]s$/;
184
+ var CJS_CTS_EXT_RE = /\.c[jt]s$/;
183
185
  var createFilter = _createFilter;
184
186
  var NODE_BUILTIN_NAMESPACE = "node:";
185
187
  var NPM_BUILTIN_NAMESPACE = "npm:";
@@ -228,9 +230,9 @@ function tryStatSync(file) {
228
230
  }
229
231
  }
230
232
  function isFilePathESM(filePath, packageCache) {
231
- if (/\.m[jt]s$/.test(filePath)) {
233
+ if (MJS_MTS_EXT_RE.test(filePath)) {
232
234
  return true;
233
- } else if (/\.c[jt]s$/.test(filePath)) {
235
+ } else if (CJS_CTS_EXT_RE.test(filePath)) {
234
236
  return false;
235
237
  } else {
236
238
  try {
@@ -303,6 +305,7 @@ var dynamicImport = async (id, { format }) => {
303
305
  };
304
306
 
305
307
  // src/externalize.ts
308
+ var NON_RELATIVE_NON_HASH_RE = /^[^.#].*/;
306
309
  function createExternalizeDepsPlugin({
307
310
  entryFile,
308
311
  isESM
@@ -313,7 +316,7 @@ function createExternalizeDepsPlugin({
313
316
  return {
314
317
  name: "externalize-deps",
315
318
  resolveId: {
316
- filter: { id: /^[^.#].*/ },
319
+ filter: { id: NON_RELATIVE_NON_HASH_RE },
317
320
  async handler(id, importer, options) {
318
321
  const { kind } = options;
319
322
  if (!importer || path3.isAbsolute(id) || isNodeBuiltin(id)) {
@@ -507,6 +510,7 @@ async function getModuleSyncConditionEnabled() {
507
510
  }
508
511
 
509
512
  // src/bundler.ts
513
+ var JS_TS_EXT_RE = /\.[cm]?[jt]s$/;
510
514
  async function bundleFile(fileName, options) {
511
515
  const { isESM } = options;
512
516
  const dirnameVarName = "__vite_injected_original_dirname";
@@ -622,7 +626,7 @@ function createFileScopeVariablesPlugin({
622
626
  return {
623
627
  name: "inject-file-scope-variables",
624
628
  transform: {
625
- filter: { id: /\.[cm]?[jt]s$/ },
629
+ filter: { id: JS_TS_EXT_RE },
626
630
  async handler(code, id) {
627
631
  const injectValues = `const ${dirnameVarName} = ${JSON.stringify(path4.dirname(id))};const ${filenameVarName} = ${JSON.stringify(id)};const ${importMetaUrlVarName} = ${JSON.stringify(
628
632
  pathToFileURL2(id).href
@@ -870,8 +874,9 @@ import os2 from "os";
870
874
  import path6 from "path";
871
875
  import process5 from "process";
872
876
  import { pathToFileURL as pathToFileURL4 } from "url";
877
+ var NON_WORD_CHAR_RE = /[^\w.-]/g;
873
878
  function sanitizeFilename(name) {
874
- return name.replace(/[^\w.-]/g, "_");
879
+ return name.replace(NON_WORD_CHAR_RE, "_");
875
880
  }
876
881
  async function resolveTempOutputFile(sourceFile, code, options) {
877
882
  const getOutputFile = options.getOutputFile || defaultGetOutputFile;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rolldown-require",
3
3
  "type": "module",
4
- "version": "2.0.6",
4
+ "version": "2.0.7",
5
5
  "description": "bundle and require a file using rolldown!",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -48,7 +48,7 @@
48
48
  "node": "^20.19.0 || >=22.12.0"
49
49
  },
50
50
  "peerDependencies": {
51
- "rolldown": ">=1.0.0-rc.3"
51
+ "rolldown": ">=1.0.0-rc.9"
52
52
  },
53
53
  "dependencies": {
54
54
  "@rollup/pluginutils": "^5.3.0",
@@ -63,6 +63,7 @@
63
63
  "build": "tsup",
64
64
  "test": "vitest run",
65
65
  "test:dev": "vitest",
66
+ "typecheck": "tsc --noEmit",
66
67
  "release": "pnpm publish",
67
68
  "lint": "eslint .",
68
69
  "lint:fix": "eslint . --fix"