Skip to content

Commit 50df9b1

Browse files
Jontemblakeembrey
authored andcommitted
Fix preloading of modules (#258)
1 parent b2e6990 commit 50df9b1

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/_bin.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,7 @@ const service = register({
161161
})
162162

163163
// Require specified modules before start-up.
164-
for (const id of arrify(argv.require)) {
165-
Module._load(id)
166-
}
164+
;(Module as any)._preloadModules(arrify(argv.require))
167165

168166
/**
169167
* Eval helpers.

src/index.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,15 @@ describe('ts-node', function () {
169169
return done()
170170
})
171171
})
172+
173+
it('should support require from node modules', function (done) {
174+
exec(`${BIN_EXEC} -r typescript -e "console.log('success')"`, function (err, stdout) {
175+
expect(err).to.not.exist
176+
expect(stdout).to.equal('success\n')
177+
178+
return done()
179+
})
180+
})
172181
})
173182

174183
describe('register', function () {

0 commit comments

Comments
 (0)