-
-
Notifications
You must be signed in to change notification settings - Fork 532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add moduleType option to override module type on certain files. #1371
Conversation
refactor resolverFunctions into their own file; should break this into 2x PRs later.
Codecov Report
|
👋 thanks for the help in #1337 @cspotcode - glad to offer a bit of help in return (or to try to, at least :)). If you could provide some of that guidance re: test cases I'll start to take a look soon. |
Since the coverage report is pretty big, I'll highlight some specific lines and the tests that will cover them. Please don't let the verbosity scare you; I erred on the side of including too much detail. Missing coverage: https://app.codecov.io/gh/TypeStrong/ts-node/compare/1371/diff#D2L115The test I wrote for this PR (https://github.com/TypeStrong/ts-node/pull/1371/files#diff-1d9efcccb250238d73480e5c49afae61494dd3103e9a16c38d36979f27c6ff90R1468-R1474) tests when you try to However, there's another code path I neglected to test: when you try to In the linked code coverage, those 2x return statements are when there's an override forcing a file to be CJS and ESM, respectively. I believe you should be able to copy-paste the test I wrote and then modify it to test this new situation. You can see I added a When our tests run, they actually |
Getting closer to having the additional test coverage available to offer here. One question so far: when using |
I think we use either the TS_NODE_PROJECT env var, or else we rely on
auto-detection based on CWD. But I believe for these tests the cwd is one
level too high so we use the env var. You might have some luck copying
what we do for other --loader tests.
…On Sun, Jun 20, 2021, 1:01 PM James Addison ***@***.***> wrote:
Getting closer to having the additional test coverage available to offer
here.
One question so far: when using node --loader ts-node/esm ... as the
command-under-test, is there a way to indicate the path to the
tsconfig.json file, similar to the --project flag when using the ts-node
command directly?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1371 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAC35OEYGR2KZMIAIFCB53TTTYNFDANCNFSM46NNMPBQ>
.
|
* Test coverage: add test case to confirm that moduleType overrides are applied for ts-node in loader mode * Ensure that a default export exists for the esm-exception module * Re-order tsconfig.json glob rules, and use implicit globbing * lint fixup: apply prettier * Add 'experimental-specifier-resolution' flag to NPM options in ESM module override test * Ensure that a default export exists for the cjs-subdir module * Revert "Ensure that a default export exists for the cjs-subdir module" This reverts commit c64cf92. * Revert "Add 'experimental-specifier-resolution' flag to NPM options in ESM module override test" This reverts commit 1093df8. * Specify tsconfig project using TS_NODE_PROJECT environment variable * Use full file paths in preference to directory-default module imports This avoids ERR_UNSUPPORTED_DIR_IMPORT, without having to provide the 'experimental-specifier-resolution' flag to ts-node * Update index.ts * Update index.ts * Update tsconfig.json * Extract execModuleTypeOverride function * Add expected failure cases for Node 12.15, 14.13 Co-authored-by: Andrew Bradley <cspotcode@gmail.com>
Thanks for the credit offer @cspotcode; only required if the tests end up being enabled in the test suite. I'll take a look into the |
No worries, I feel confident finishing this myself. After merging your PR,
I spent some time tweaking and squashing errors. I have one more test
failure to eliminate, but after that, I think we're good to go!
…On Fri, Jul 9, 2021, 3:52 AM James Addison ***@***.***> wrote:
Thanks for the credit offer @cspotcode <https://github.com/cspotcode>;
only required if the tests end up being enabled in the test suite. I'll
take a look into the volta Node version manager soon, but don't wait on
me (and feel free to remove the commented tests (and credit) if they're not
ready; less noise in the codebase).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1371 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAC35OESBYOE65MLIZUYVYLTW2TFTANCNFSM46NNMPBQ>
.
|
Only failure is a drop in code coverage, but I've reviewed the coverage report to determine that everything important is covered. |
Attempting an implementation of #1342
Closes #1342
Be sure @jayaddison gets credit for #1376 in the release notes.
Also refactors
createResolverFunctions
into its own file; should break this into 2x PRs later.TODOs
ts-internals.ts
as@internal
--showConfig
moduleTypes
log correct, relative paths same asinclude
(not done, but extracted to Make--showConfig
moduleTypes
log correct, relative paths same asinclude
#1389)include
is specified in an extended tsconfig in another directory,--showConfig
correctly updates relative paths so they render correctly.