@hirarijs/loader-cjs-interop 1.0.13 → 1.0.14
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.cjs +4 -0
- package/dist/index.js +6 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -60,6 +60,8 @@ function runTransform(code, filename, ctx) {
|
|
|
60
60
|
}
|
|
61
61
|
let exportKeys = [];
|
|
62
62
|
try {
|
|
63
|
+
;
|
|
64
|
+
globalThis[import_loader.BYPASS_FLAG] = true;
|
|
63
65
|
const req = (0, import_module.createRequire)(import_meta.url);
|
|
64
66
|
const mod = req(filename);
|
|
65
67
|
if (mod && typeof mod === "object") {
|
|
@@ -73,6 +75,8 @@ function runTransform(code, filename, ctx) {
|
|
|
73
75
|
console.log(`[loader-cjs-interop] imported ${filename}`);
|
|
74
76
|
}
|
|
75
77
|
return { code, continue: true };
|
|
78
|
+
} finally {
|
|
79
|
+
delete globalThis[import_loader.BYPASS_FLAG];
|
|
76
80
|
}
|
|
77
81
|
const lines = [];
|
|
78
82
|
lines.push(`// ${WRAP_MARK}`);
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import { createRequire } from "module";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import {
|
|
5
|
-
IMPORT_META_URL_VARIABLE
|
|
5
|
+
IMPORT_META_URL_VARIABLE,
|
|
6
|
+
BYPASS_FLAG
|
|
6
7
|
} from "@hirarijs/loader";
|
|
7
8
|
var extensions = [".js", ".cjs"];
|
|
8
9
|
var isValidIdent = (name) => /^[A-Za-z_$][0-9A-Za-z_$]*$/.test(name);
|
|
@@ -27,6 +28,8 @@ function runTransform(code, filename, ctx) {
|
|
|
27
28
|
}
|
|
28
29
|
let exportKeys = [];
|
|
29
30
|
try {
|
|
31
|
+
;
|
|
32
|
+
globalThis[BYPASS_FLAG] = true;
|
|
30
33
|
const req = createRequire(import.meta.url);
|
|
31
34
|
const mod = req(filename);
|
|
32
35
|
if (mod && typeof mod === "object") {
|
|
@@ -40,6 +43,8 @@ function runTransform(code, filename, ctx) {
|
|
|
40
43
|
console.log(`[loader-cjs-interop] imported ${filename}`);
|
|
41
44
|
}
|
|
42
45
|
return { code, continue: true };
|
|
46
|
+
} finally {
|
|
47
|
+
delete globalThis[BYPASS_FLAG];
|
|
43
48
|
}
|
|
44
49
|
const lines = [];
|
|
45
50
|
lines.push(`// ${WRAP_MARK}`);
|