File tree 1 file changed +15
-4
lines changed
1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change 1
1
import path from 'path' ;
2
2
import findup from 'findup-sync' ;
3
- import esm from 'esm' ;
4
-
5
- const esmRequire = esm ( module ) ;
6
3
7
4
interface LoadBrocfileOptions {
8
5
brocfilePath ?: string ;
@@ -37,8 +34,22 @@ function requireBrocfile(brocfilePath: string) {
37
34
// Load brocfile via ts-node
38
35
brocfile = require ( brocfilePath ) ;
39
36
} else {
37
+ /**
38
+ * because 'esm' patches global modules,
39
+ * let's only load 'esm' if we absolutely have to.
40
+ * See context: https://github.com/broccolijs/broccoli/issues/498
41
+ * (and related linkes)
42
+ */
43
+ try {
44
+ brocfile = require ( brocfilePath ) ;
45
+ } catch {
46
+ // eslint-disable-next-line @typescript-eslint/no-var-requires, node/no-missing-require
47
+ const esm = require ( 'esm' ) ;
48
+ const esmRequire = esm ( module ) ;
49
+
50
+ brocfile = esmRequire ( brocfilePath ) ;
51
+ }
40
52
// Load brocfile via esm shim
41
- brocfile = esmRequire ( brocfilePath ) ;
42
53
}
43
54
44
55
// ESM `export default X` is represented as module.exports = { default: X }
You can’t perform that action at this time.
0 commit comments