@modern-js/node-bundle-require 2.35.0 → 2.35.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.
@@ -48,12 +48,11 @@ async function isTypeModulePkg(cwd) {
48
48
  }
49
49
  const defaultGetOutputFile = async (filepath) => _path.default.resolve(_utils.CONFIG_CACHE_DIR, `${filepath.replace(/\.(js|ts)/, "")}.${(0, _utils.nanoid)(8)}.cjs`);
50
50
  async function bundle(filepath, options) {
51
- var _options, _options1, _options2, _options3;
52
51
  if (!JS_EXT_RE.test(filepath)) {
53
52
  throw new Error(`${filepath} is not a valid JS file`);
54
53
  }
55
54
  debug("bundle", filepath, options);
56
- const getOutputFile = ((_options = options) === null || _options === void 0 ? void 0 : _options.getOutputFile) || defaultGetOutputFile;
55
+ const getOutputFile = (options === null || options === void 0 ? void 0 : options.getOutputFile) || defaultGetOutputFile;
57
56
  const outfile = await getOutputFile(_path.default.basename(filepath));
58
57
  const esbuildOptions = {
59
58
  entryPoints: [
@@ -67,9 +66,9 @@ async function bundle(filepath, options) {
67
66
  // sets `target: "es5"`
68
67
  // reference: https://github.com/evanw/esbuild/releases/tag/v0.12.6
69
68
  target: "esnext",
70
- ...(_options1 = options) === null || _options1 === void 0 ? void 0 : _options1.esbuildOptions,
69
+ ...options === null || options === void 0 ? void 0 : options.esbuildOptions,
71
70
  plugins: [
72
- ...((_options2 = options) === null || _options2 === void 0 ? void 0 : _options2.esbuildPlugins) || [],
71
+ ...(options === null || options === void 0 ? void 0 : options.esbuildPlugins) || [],
73
72
  // https://github.com/evanw/esbuild/issues/1051#issuecomment-806325487
74
73
  {
75
74
  name: "native-node-modules",
@@ -154,7 +153,7 @@ async function bundle(filepath, options) {
154
153
  }
155
154
  ]
156
155
  };
157
- if ((_options3 = options) === null || _options3 === void 0 ? void 0 : _options3.watch) {
156
+ if (options === null || options === void 0 ? void 0 : options.watch) {
158
157
  const ctx = await (0, _esbuild.context)(esbuildOptions);
159
158
  await ctx.rebuild();
160
159
  await ctx.watch();
package/dist/cjs/index.js CHANGED
@@ -23,16 +23,14 @@ _export(exports, {
23
23
  const _utils = require("@modern-js/utils");
24
24
  const _bundle = require("./bundle");
25
25
  async function bundleRequire(filepath, options) {
26
- var _options;
27
26
  const configFile = await (0, _bundle.bundle)(filepath, options);
28
27
  let mod;
29
- const req = ((_options = options) === null || _options === void 0 ? void 0 : _options.require) || require;
28
+ const req = (options === null || options === void 0 ? void 0 : options.require) || require;
30
29
  try {
31
30
  mod = await req(configFile);
32
31
  (0, _utils.deleteRequireCache)(configFile);
33
32
  } finally {
34
- var _options1;
35
- if (((_options1 = options) === null || _options1 === void 0 ? void 0 : _options1.autoClear) === void 0 || options.autoClear) {
33
+ if ((options === null || options === void 0 ? void 0 : options.autoClear) === void 0 || options.autoClear) {
36
34
  _utils.fs.unlinkSync(configFile);
37
35
  }
38
36
  }
@@ -25,12 +25,11 @@ async function isTypeModulePkg(cwd) {
25
25
  }
26
26
  export const defaultGetOutputFile = async (filepath) => path.resolve(CONFIG_CACHE_DIR, `${filepath.replace(/\.(js|ts)/, "")}.${nanoid(8)}.cjs`);
27
27
  export async function bundle(filepath, options) {
28
- var _options, _options1, _options2, _options3;
29
28
  if (!JS_EXT_RE.test(filepath)) {
30
29
  throw new Error(`${filepath} is not a valid JS file`);
31
30
  }
32
31
  debug("bundle", filepath, options);
33
- const getOutputFile = ((_options = options) === null || _options === void 0 ? void 0 : _options.getOutputFile) || defaultGetOutputFile;
32
+ const getOutputFile = (options === null || options === void 0 ? void 0 : options.getOutputFile) || defaultGetOutputFile;
34
33
  const outfile = await getOutputFile(path.basename(filepath));
35
34
  const esbuildOptions = {
36
35
  entryPoints: [
@@ -44,9 +43,9 @@ export async function bundle(filepath, options) {
44
43
  // sets `target: "es5"`
45
44
  // reference: https://github.com/evanw/esbuild/releases/tag/v0.12.6
46
45
  target: "esnext",
47
- ...(_options1 = options) === null || _options1 === void 0 ? void 0 : _options1.esbuildOptions,
46
+ ...options === null || options === void 0 ? void 0 : options.esbuildOptions,
48
47
  plugins: [
49
- ...((_options2 = options) === null || _options2 === void 0 ? void 0 : _options2.esbuildPlugins) || [],
48
+ ...(options === null || options === void 0 ? void 0 : options.esbuildPlugins) || [],
50
49
  // https://github.com/evanw/esbuild/issues/1051#issuecomment-806325487
51
50
  {
52
51
  name: "native-node-modules",
@@ -131,7 +130,7 @@ export async function bundle(filepath, options) {
131
130
  }
132
131
  ]
133
132
  };
134
- if ((_options3 = options) === null || _options3 === void 0 ? void 0 : _options3.watch) {
133
+ if (options === null || options === void 0 ? void 0 : options.watch) {
135
134
  const ctx = await context(esbuildOptions);
136
135
  await ctx.rebuild();
137
136
  await ctx.watch();
package/dist/esm/index.js CHANGED
@@ -2,16 +2,14 @@ import { fs, deleteRequireCache } from "@modern-js/utils";
2
2
  import { bundle, defaultGetOutputFile } from "./bundle";
3
3
  export { bundle, defaultGetOutputFile };
4
4
  export async function bundleRequire(filepath, options) {
5
- var _options;
6
5
  const configFile = await bundle(filepath, options);
7
6
  let mod;
8
- const req = ((_options = options) === null || _options === void 0 ? void 0 : _options.require) || require;
7
+ const req = (options === null || options === void 0 ? void 0 : options.require) || require;
9
8
  try {
10
9
  mod = await req(configFile);
11
10
  deleteRequireCache(configFile);
12
11
  } finally {
13
- var _options1;
14
- if (((_options1 = options) === null || _options1 === void 0 ? void 0 : _options1.autoClear) === void 0 || options.autoClear) {
12
+ if ((options === null || options === void 0 ? void 0 : options.autoClear) === void 0 || options.autoClear) {
15
13
  fs.unlinkSync(configFile);
16
14
  }
17
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modern-js/node-bundle-require",
3
- "version": "2.35.0",
3
+ "version": "2.35.1",
4
4
  "description": "A Progressive React Framework for modern web development.",
5
5
  "homepage": "https://modernjs.dev",
6
6
  "bugs": "https://github.com/web-infra-dev/modern.js/issues",
@@ -47,15 +47,15 @@
47
47
  "dependencies": {
48
48
  "esbuild": "0.17.19",
49
49
  "@swc/helpers": "0.5.1",
50
- "@modern-js/utils": "2.35.0"
50
+ "@modern-js/utils": "2.35.1"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/jest": "^29",
54
54
  "@types/node": "^14",
55
55
  "jest": "^29",
56
56
  "typescript": "^5",
57
- "@scripts/build": "2.35.0",
58
- "@scripts/jest-config": "2.35.0"
57
+ "@scripts/build": "2.35.1",
58
+ "@scripts/jest-config": "2.35.1"
59
59
  },
60
60
  "sideEffects": false,
61
61
  "publishConfig": {