Skip to content

Commit

Permalink
fix: Alias --es-module-specifier-resolution to --experimental-specifi…
Browse files Browse the repository at this point in the history
…er-resolution for Node 12 compatibility (#1122)

* fix: Alias --es-module-specifier-resolution to --experimental-specifier-resolution for node 12 compatibility

* Update node-options.js

Co-authored-by: Andrew Bradley <cspotcode@gmail.com>
  • Loading branch information
nguyensomniac and cspotcode committed Sep 15, 2020
1 parent 41e7109 commit 4dba8e8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion dist-raw/node-options.js
Expand Up @@ -25,7 +25,9 @@ function parseArgv(argv) {
'--preserve-symlinks': Boolean,
'--preserve-symlinks-main': Boolean,
'--input-type': String,
'--experimental-specifier-resolution': String
'--experimental-specifier-resolution': String,
// Legacy alias for node versions prior to 12.16
'--es-module-specifier-resolution': '--experimental-specifier-resolution',
}, {
argv,
permissive: true
Expand Down
2 changes: 1 addition & 1 deletion esm-usage-example/package.json
@@ -1,7 +1,7 @@
{
"type": "module",
"dependencies": {
"ts-node": "github:TypeStrong/ts-node#ab/esm-support",
"ts-node": "github:TypeStrong/ts-node#master",
"typescript": "^3.8.3"
}
}
8 changes: 8 additions & 0 deletions src/index.spec.ts
Expand Up @@ -887,6 +887,14 @@ describe('ts-node', function () {
return done()
})
})
it('via --es-module-specifier-resolution alias', (done) => {
exec(`${cmd} --experimental-modules --es-module-specifier-resolution=node index.ts`, { cwd: join(__dirname, '../tests/esm-node-resolver') }, function (err, stdout) {
expect(err).to.equal(null)
expect(stdout).to.equal('foo bar baz biff\n')

return done()
})
})
it('via NODE_OPTIONS', (done) => {
exec(`${cmd} index.ts`, {
cwd: join(__dirname, '../tests/esm-node-resolver'),
Expand Down

0 comments on commit 4dba8e8

Please sign in to comment.