@@ -17,10 +17,6 @@ export const HELPERS_ID = '\0commonjsHelpers.js';
17
17
export const HELPERS = `
18
18
export var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
19
19
20
- export function commonjsRegister (path, loader) {
21
- DYNAMIC_REQUIRE_LOADERS[path] = loader;
22
- }
23
-
24
20
export function unwrapExports (x) {
25
21
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
26
22
}
@@ -32,6 +28,18 @@ export function createCommonjsModule(fn, module) {
32
28
export function getCjsExportFromNamespace (n) {
33
29
return n && n['default'] || n;
34
30
}
31
+ ` ;
32
+
33
+ export const HELPER_NON_DYNAMIC = `
34
+ export function commonjsRequire () {
35
+ throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
36
+ }
37
+ ` ;
38
+
39
+ export const HELPERS_DYNAMIC = `
40
+ export function commonjsRegister (path, loader) {
41
+ DYNAMIC_REQUIRE_LOADERS[path] = loader;
42
+ }
35
43
36
44
const DYNAMIC_REQUIRE_LOADERS = Object.create(null);
37
45
const DYNAMIC_REQUIRE_CACHE = Object.create(null);
@@ -63,6 +71,7 @@ function normalize (path) {
63
71
path = '.';
64
72
return path;
65
73
}
74
+
66
75
function join () {
67
76
if (arguments.length === 0)
68
77
return '.';
@@ -81,6 +90,7 @@ function join () {
81
90
82
91
return joined;
83
92
}
93
+
84
94
function isPossibleNodeModulesPath (modulePath) {
85
95
let c0 = modulePath[0];
86
96
if (c0 === '/' || c0 === '\\\\') return false;
@@ -91,6 +101,7 @@ function isPossibleNodeModulesPath (modulePath) {
91
101
return false;
92
102
return true;
93
103
}
104
+
94
105
export function commonjsRequire (path, originalModuleDir) {
95
106
const shouldTryNodeModules = isPossibleNodeModulesPath(path);
96
107
path = normalize(path);
0 commit comments