-
-
Notifications
You must be signed in to change notification settings - Fork 532
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ts-node-esm
/ --esm
to spawn a child process; decouple config loa…
…ding from `create()`; fix pluggable dep resolution (#1655) * WIP * lint-fix * WIP * it works! * Update index.ts * Move `preferTsExts` from `RegisterOptions` to `CreateOptions` * fix * fix * fix tests * fix? * fix * fix? * fix? * fix! * fix * fix!! * fix * fix... * tweak test lib's suite delimiter to match ava's * fix * fix * docs, fixes * fix #1662 and add tests * lint-fix * test cleanup, remove or cleanup version checks, skip failing tsconfig "extends" tests on TS 2.7 * ensure tests are forced to install and use most recent ts-node tarball and cannot accidentally use project-root nor outdated tarball * fix absence of fs method on old node
- Loading branch information
Showing
60 changed files
with
1,139 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const expect = require('expect'); | ||
const { createRequire } = require('module'); | ||
|
||
module.exports = { | ||
files: ['dist/test/**/*.spec.js'], | ||
failWithoutAssertions: false, | ||
environmentVariables: { | ||
ts_node_install_lock: `id-${Math.floor(Math.random() * 10e9)}`, | ||
// Force jest expect() errors to generate colorized strings, makes output more readable. | ||
// Delete the env var within ava processes via `require` option below. | ||
// This avoids passing it to spawned processes under test, which would negatively affect | ||
// their behavior. | ||
FORCE_COLOR: '3', | ||
}, | ||
require: ['./src/test/remove-env-var-force-color.js'], | ||
timeout: '300s', | ||
concurrency: 1, | ||
}; | ||
|
||
{ | ||
/* | ||
* Tests *must* install and use our most recent ts-node tarball. | ||
* We must prevent them from accidentally require-ing a different version of | ||
* ts-node, from either node_modules or tests/node_modules | ||
*/ | ||
|
||
const { existsSync } = require('fs'); | ||
const rimraf = require('rimraf'); | ||
const { resolve } = require('path'); | ||
|
||
remove(resolve(__dirname, 'node_modules/ts-node')); | ||
remove(resolve(__dirname, 'tests/node_modules/ts-node')); | ||
|
||
// Prove that we did it correctly | ||
expect(() => {createRequire(resolve(__dirname, 'tests/foo.js')).resolve('ts-node')}).toThrow(); | ||
|
||
function remove(p) { | ||
if(existsSync(p)) rimraf.sync(p, {recursive: true}) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { fileURLToPath } from 'url'; | ||
import { createRequire } from 'module'; | ||
const require = createRequire(fileURLToPath(import.meta.url)); | ||
|
||
/** @type {import('./dist/child-loader')} */ | ||
const childLoader = require('./dist/child/child-loader'); | ||
export const { resolve, load, getFormat, transformSource } = childLoader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env node | ||
|
||
import { main } from './bin'; | ||
|
||
main(undefined, { '--esm': true }); |
Oops, something went wrong.