-
-
Notifications
You must be signed in to change notification settings - Fork 536
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 path mapping support to ESM and CJS loaders #1585
Open
geigerzaehler
wants to merge
79
commits into
TypeStrong:main
Choose a base branch
from
geigerzaehler:path-mapping
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,430
−38
Open
Changes from all commits
Commits
Show all changes
79 commits
Select commit
Hold shift + click to select a range
3be1fde
Add path mapping support to ESM loader
geigerzaehler c542d98
fixup! Add path mapping support to ESM loader
geigerzaehler 0cbfa6c
fixup! fixup! Add path mapping support to ESM loader
geigerzaehler e7082b1
fixup! fixup! fixup! Add path mapping support to ESM loader
geigerzaehler 69a397b
Merge remote-tracking branch 'origin/main' into path-mapping
cspotcode 2fcb982
address code review comments
geigerzaehler 48f5262
map esm paths in all included files
geigerzaehler a19454b
improve error message when mapped module is not found
geigerzaehler 32e26e8
Review changes; add CommonJS path mapping
cspotcode 362935b
fix failing tests
cspotcode e573fd7
add path mapping to docs
cspotcode 0012b22
add flag to enable/disable path mapping in the two loaders
cspotcode b6352e3
fix windows tests?
cspotcode 85643fd
fix windows tests?
cspotcode 9c46688
Merge remote-tracking branch 'origin/main' into path-mapping
cspotcode bede1b6
add path mapping option to docs
cspotcode 80746c2
changes
cspotcode 885b7b1
replace equal (deprecated) with strictEqual
charles-allen c3dbe73
extract shared tsconfig
charles-allen 8c5fd23
move import targets 2-deep (to support combined baseUrl + * path)
charles-allen e66d236
test: baseUrl + no paths
charles-allen 23f40b1
test: baseUrl + * path
charles-allen 54fdbba
test: fallback to node_modules
charles-allen 78652b2
clean up destructuring
charles-allen b8e6fb7
fix setting project
charles-allen 2973399
test: fallback to built-in
charles-allen 5ffd905
avoid space in command & add comment
charles-allen d200301
fix setting project and PATH
charles-allen c621af0
test: skip type-defs
charles-allen ec038c1
test: external imports ignore paths
charles-allen d471d1d
tests: relative/base-relative imports ignore paths
charles-allen d5728dc
Merge remote-tracking branch 'origin/main' into path-mapping
cspotcode 5b686e1
Updates
cspotcode cb3706e
add missing package.json from node_modules
cspotcode d00bf73
rolling back a config change; I was wrong
cspotcode 398db86
add helper execEsm(...)
charles-allen a91d5d7
test: decouple base-url-no-paths test (by extracting it)
charles-allen 7829b54
test: decouple skip-type-definition test (by extracting it)
charles-allen 9fd944e
test: refactor to apply tests across multiple module types & project …
charles-allen 4e0d363
temporarily move old tests out of the way
charles-allen 09cc514
test: refactor again to restore shared examples/node_modules (while m…
charles-allen 70d9bf5
import `assert` async so we can assert pre-conditions (& so sut impor…
charles-allen e50abd4
sync tsconfigs
charles-allen 73d6acc
fix error message in `import-node-built-in` (it's not a precondition)
charles-allen d02cbed
try to clean up cjs imports :/
charles-allen 283309d
simplify tests
charles-allen f2e2f65
test: restore "ignore type definition" tests
charles-allen 93ac2ac
delete obsolete examples
charles-allen bf7bfcd
fix star paths
charles-allen c26b9dd
move old tests a bit more out of the way
charles-allen 09ebf63
Merge remote-tracking branch 'origin/main' into path-mapping
cspotcode e0af738
ensure ts-node is installed before running tests
cspotcode 31acd50
disable typechecking in tests
cspotcode 36377fc
test: add a case that imports an esm lib from node_modules
charles-allen 56ef378
use require everywhere in cjs examples
charles-allen 4dcff42
destructure import proxyLodash; align both depends-on-lodash deps as cjs
charles-allen ba176bf
fix baseUrl
charles-allen 38ad3f5
revert assertions to use expect(err).toBeNull(); Clean up config cons…
charles-allen 1687de9
prefer function declaration to arrow function
charles-allen 8e9b117
move base 2 deep, so star path can be used in addition to base
charles-allen 806ce74
tests: non-relative imports
charles-allen 0fd8a5c
fix import extensions
charles-allen 02818e3
tests: imports from js, jsx, tsx
charles-allen 6faedd9
rename under-base to below-base (nicer lexical sort)
charles-allen 64bb679
tests: relative imports
charles-allen 058d2e2
tests: import invalid path
charles-allen 4a3b6b4
test: should not use star-path to resolve relative import
charles-allen dc7e950
tests: basic path mapping
charles-allen c5ea9b0
fix import style
charles-allen 7bfe31a
tests: map using first available candidate
charles-allen c8c35ca
tests: more specific path; static path
charles-allen 99ca516
comment out file-system-base-relative import
charles-allen 4fefc57
tests: mapping from js, jsx, tsx files
charles-allen 3a0067e
clean up (delete all old tests)
charles-allen 78e3eda
tweaks before pulling in the latest main branch
cspotcode 4f5bc35
Merge remote-tracking branch 'origin/main' into path-mapping
cspotcode ef926b9
fix
cspotcode 7552fc4
style tweak
cspotcode 6632481
turn on experimental resolver; add required file extensions to esm tests
cspotcode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,29 @@ | ||
exports.codes = {}; | ||
|
||
function defineError(code, buildMessage) { | ||
if (!buildMessage) { | ||
buildMessage = (...args) => args.join(' '); | ||
} | ||
|
||
exports.codes[code] = class CustomError extends Error { | ||
constructor(...args) { | ||
super(`${code}: ${buildMessage(...args)}`); | ||
this.code = code; | ||
} | ||
} | ||
} | ||
|
||
defineError("ERR_INPUT_TYPE_NOT_ALLOWED"); | ||
defineError("ERR_INVALID_ARG_VALUE"); | ||
defineError("ERR_INVALID_MODULE_SPECIFIER"); | ||
defineError("ERR_INVALID_PACKAGE_CONFIG"); | ||
defineError("ERR_INVALID_PACKAGE_TARGET"); | ||
defineError("ERR_MANIFEST_DEPENDENCY_MISSING"); | ||
defineError("ERR_MODULE_NOT_FOUND", (path, base, type = 'package') => { | ||
return `Cannot find ${type} '${path}' imported from ${base}`; | ||
}); | ||
defineError("ERR_PACKAGE_IMPORT_NOT_DEFINED"); | ||
defineError("ERR_PACKAGE_PATH_NOT_EXPORTED"); | ||
defineError("ERR_UNSUPPORTED_DIR_IMPORT"); | ||
defineError("ERR_UNSUPPORTED_ESM_URL_SCHEME"); | ||
defineError("ERR_UNKNOWN_FILE_EXTENSION"); |
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this portion of the file exactly identical to
dist-raw/node-errors.js
?