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