File tree 5 files changed +16
-37
lines changed
5 files changed +16
-37
lines changed Original file line number Diff line number Diff line change @@ -87,20 +87,17 @@ jobs:
87
87
os : windows-latest
88
88
shell : cmd
89
89
node-version :
90
- - 18.17.0
91
- - 18.x
92
- - 20.5.0
90
+ - 20.17.0
93
91
- 20.x
92
+ - 22.9.0
94
93
- 22.x
95
94
exclude :
96
95
- platform : { name: macOS, os: macos-13, shell: bash }
97
- node-version : 18.17.0
98
- - platform : { name: macOS, os: macos-13, shell: bash }
99
- node-version : 18.x
100
- - platform : { name: macOS, os: macos-13, shell: bash }
101
- node-version : 20.5.0
96
+ node-version : 20.17.0
102
97
- platform : { name: macOS, os: macos-13, shell: bash }
103
98
node-version : 20.x
99
+ - platform : { name: macOS, os: macos-13, shell: bash }
100
+ node-version : 22.9.0
104
101
- platform : { name: macOS, os: macos-13, shell: bash }
105
102
node-version : 22.x
106
103
runs-on : ${{ matrix.platform.os }}
Original file line number Diff line number Diff line change @@ -68,20 +68,17 @@ jobs:
68
68
os : windows-latest
69
69
shell : cmd
70
70
node-version :
71
- - 18.17.0
72
- - 18.x
73
- - 20.5.0
71
+ - 20.17.0
74
72
- 20.x
73
+ - 22.9.0
75
74
- 22.x
76
75
exclude :
77
76
- platform : { name: macOS, os: macos-13, shell: bash }
78
- node-version : 18.17.0
79
- - platform : { name: macOS, os: macos-13, shell: bash }
80
- node-version : 18.x
81
- - platform : { name: macOS, os: macos-13, shell: bash }
82
- node-version : 20.5.0
77
+ node-version : 20.17.0
83
78
- platform : { name: macOS, os: macos-13, shell: bash }
84
79
node-version : 20.x
80
+ - platform : { name: macOS, os: macos-13, shell: bash }
81
+ node-version : 22.9.0
85
82
- platform : { name: macOS, os: macos-13, shell: bash }
86
83
node-version : 22.x
87
84
runs-on : ${{ matrix.platform.os }}
Original file line number Diff line number Diff line change 3
3
// then subsequent requires for the same path would return an empty object. Not
4
4
// sure if a bug or I'm doing something wrong but since the require/imports here
5
5
// are short lived, it is safe to create our own cache and use that.
6
- const { pathToFileURL } = require ( 'url' )
7
6
8
7
const importOrRequireCache = new Map ( )
9
8
@@ -14,21 +13,12 @@ const importOrRequire = async path => {
14
13
let content = { }
15
14
try {
16
15
content = require ( path )
17
- // this is for node 22+
18
- // istanbul ignore next
19
16
if ( content . __esModule ) {
20
- return content . default
17
+ content = content . default
21
18
}
22
19
} catch {
23
- try {
24
- // this is for node under 18
25
- const results = await import ( pathToFileURL ( path ) )
26
- // istanbul ignore next
27
- return results . default
28
- } catch {
29
- // its ok if this fails since the content dir might only be to provide
30
- // other files. the index.js is optional
31
- }
20
+ // its ok if this fails since the content dir might only be to provide
21
+ // other files. the index.js is optional
32
22
}
33
23
importOrRequireCache . set ( path , content )
34
24
return content
Original file line number Diff line number Diff line change 94
94
"prettier" : true
95
95
},
96
96
"engines" : {
97
- "node" : " ^18 .17.0 || >=20.5 .0"
97
+ "node" : " ^20 .17.0 || >=22.9 .0"
98
98
},
99
99
"workspaces" : [
100
100
" workspace/test-workspace"
Original file line number Diff line number Diff line change @@ -20,13 +20,8 @@ t.test('importOrRequire', async t => {
20
20
const typeModule = await importOrRequire ( path . join ( dir , 'esm/index.js' ) )
21
21
t . same ( typeModule , 'type module' )
22
22
23
- if ( process . version . replace ( 'v' , '' ) . split ( '.' ) [ 0 ] >= '22' ) {
24
- const results = await importOrRequire ( path . join ( dir , 'esm.js' ) )
25
- t . same ( results , 'esm' )
26
- } else {
27
- const results = await importOrRequire ( path . join ( dir , 'esm.js' ) )
28
- t . same ( results , { } )
29
- }
23
+ const results = await importOrRequire ( path . join ( dir , 'esm.js' ) )
24
+ t . same ( results , 'esm' )
30
25
31
26
await Promise . all (
32
27
// double 'js' triggers the cache
You can’t perform that action at this time.
0 commit comments