@modern-js/utils 2.60.6 → 2.62.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -49,9 +49,14 @@ async function compatibleRequire(path, interop = true) {
49
49
  try {
50
50
  requiredModule = require(path);
51
51
  } catch (err) {
52
- if (err.code === "ERR_REQUIRE_ESM" || err instanceof SyntaxError) {
52
+ if (err.code === "ERR_REQUIRE_ESM") {
53
53
  const modulePath = (0, import_node_path.isAbsolute)(path) ? (0, import_node_url.pathToFileURL)(path).href : path;
54
- requiredModule = await import(modulePath);
54
+ if (process.env.NODE_ENV === "development") {
55
+ const timestamp = Date.now();
56
+ requiredModule = await import(`${modulePath}?t=${timestamp}`);
57
+ } else {
58
+ requiredModule = await import(modulePath);
59
+ }
55
60
  return interop ? requiredModule.default : requiredModule;
56
61
  } else {
57
62
  throw err;
@@ -1,5 +1,4 @@
1
1
  import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _instanceof } from "@swc/helpers/_/_instanceof";
3
2
  import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
4
3
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
5
4
  import { isAbsolute } from "node:path";
@@ -10,7 +9,7 @@ function compatibleRequire(path) {
10
9
  }
11
10
  function _compatibleRequire() {
12
11
  _compatibleRequire = _async_to_generator(function(path) {
13
- var interop, requiredModule, err, modulePath;
12
+ var interop, requiredModule, err, modulePath, timestamp;
14
13
  var _arguments = arguments;
15
14
  return _ts_generator(this, function(_state) {
16
15
  switch (_state.label) {
@@ -28,39 +27,58 @@ function _compatibleRequire() {
28
27
  1,
29
28
  2,
30
29
  ,
31
- 6
30
+ 9
32
31
  ]);
33
32
  requiredModule = require(path);
34
33
  return [
35
34
  3,
36
- 6
35
+ 9
37
36
  ];
38
37
  case 2:
39
38
  err = _state.sent();
40
- if (!(err.code === "ERR_REQUIRE_ESM" || _instanceof(err, SyntaxError)))
39
+ if (!(err.code === "ERR_REQUIRE_ESM"))
41
40
  return [
42
41
  3,
43
- 4
42
+ 7
44
43
  ];
45
44
  modulePath = isAbsolute(path) ? pathToFileURL(path).href : path;
45
+ if (!(process.env.NODE_ENV === "development"))
46
+ return [
47
+ 3,
48
+ 4
49
+ ];
50
+ timestamp = Date.now();
46
51
  return [
47
52
  4,
48
- import(modulePath)
53
+ import("".concat(modulePath, "?t=").concat(timestamp))
49
54
  ];
50
55
  case 3:
51
56
  requiredModule = _state.sent();
57
+ return [
58
+ 3,
59
+ 6
60
+ ];
61
+ case 4:
62
+ return [
63
+ 4,
64
+ import(modulePath)
65
+ ];
66
+ case 5:
67
+ requiredModule = _state.sent();
68
+ _state.label = 6;
69
+ case 6:
52
70
  return [
53
71
  2,
54
72
  interop ? requiredModule.default : requiredModule
55
73
  ];
56
- case 4:
74
+ case 7:
57
75
  throw err;
58
- case 5:
76
+ case 8:
59
77
  return [
60
78
  3,
61
- 6
79
+ 9
62
80
  ];
63
- case 6:
81
+ case 9:
64
82
  return [
65
83
  2,
66
84
  interop && (requiredModule === null || requiredModule === void 0 ? void 0 : requiredModule.__esModule) ? requiredModule.default : requiredModule
@@ -10,9 +10,14 @@ async function compatibleRequire(path, interop = true) {
10
10
  try {
11
11
  requiredModule = require(path);
12
12
  } catch (err) {
13
- if (err.code === "ERR_REQUIRE_ESM" || err instanceof SyntaxError) {
13
+ if (err.code === "ERR_REQUIRE_ESM") {
14
14
  const modulePath = isAbsolute(path) ? pathToFileURL(path).href : path;
15
- requiredModule = await import(modulePath);
15
+ if (process.env.NODE_ENV === "development") {
16
+ const timestamp = Date.now();
17
+ requiredModule = await import(`${modulePath}?t=${timestamp}`);
18
+ } else {
19
+ requiredModule = await import(modulePath);
20
+ }
16
21
  return interop ? requiredModule.default : requiredModule;
17
22
  } else {
18
23
  throw err;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.60.6",
18
+ "version": "2.62.0",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -161,10 +161,10 @@
161
161
  "@types/node": "^14",
162
162
  "jest": "^29",
163
163
  "typescript": "^5",
164
- "webpack": "^5.95.0",
165
- "@modern-js/types": "2.60.6",
166
- "@scripts/build": "2.60.6",
167
- "@scripts/jest-config": "2.60.6"
164
+ "webpack": "^5.96.1",
165
+ "@modern-js/types": "2.62.0",
166
+ "@scripts/build": "2.62.0",
167
+ "@scripts/jest-config": "2.62.0"
168
168
  },
169
169
  "sideEffects": false,
170
170
  "scripts": {