Skip to content

Commit

Permalink
fix: support Node 18.6+ (#37)
Browse files Browse the repository at this point in the history
* fix: add support for Node.js v18.6.0

closes #36

* Apply suggestions from code review

* refactor: replace `withShortCircuit` wrapper with direct flag injects

* chore: impr comments

* revert style changes

* update tsc step

Co-authored-by: Luke Edwards <luke.edwards05@gmail.com>
  • Loading branch information
antongolub and lukeed committed Jul 19, 2022
1 parent d65d835 commit 82c0e90
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
timeout-minutes: 3
strategy:
matrix:
nodejs: [12, 14, 16.11, 16]
nodejs: [12, 14, 16.11, 16, 18]
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"scripts": {
"build": "node build",
"types": "tsc"
"types": "tsc --skipLibCheck"
},
"dependencies": {
"esbuild": "^0.14.0"
Expand Down
10 changes: 5 additions & 5 deletions src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ export const resolve: Resolve = async function (ident, context, fallback) {
if (match = EXTN.exec(output.href)) {
ext = match[0] as Extension;
if (!context.parentURL || isTS.test(ext)) {
return { url: output.href };
return { url: output.href, shortCircuit: true };
}
// source ident exists
path = check(output.href);
if (path) return { url: path };
if (path) return { url: path, shortCircuit: true };
// parent importer is a ts file
// source ident is js & NOT exists
if (isJS.test(ext) && isTS.test(context.parentURL)) {
Expand All @@ -96,7 +96,7 @@ export const resolve: Resolve = async function (ident, context, fallback) {
if (idx > output.href.length) {
path += output.href.substring(idx);
}
return { url: path };
return { url: path, shortCircuit: true };
}
// return original, let it error
return fallback(ident, context, fallback);
Expand All @@ -107,7 +107,7 @@ export const resolve: Resolve = async function (ident, context, fallback) {

for (ext in config) {
path = check(output.href + ext);
if (path) return { url: path };
if (path) return { url: path, shortCircuit: true };
}

return fallback(ident, context, fallback);
Expand All @@ -131,7 +131,7 @@ export const load: Load = async function (uri, context, fallback) {
format: format === 'module' ? 'esm' : 'cjs',
});

return { format, source: result.code };
return { format, source: result.code, shortCircuit: true };
}

/** @deprecated */
Expand Down

0 comments on commit 82c0e90

Please sign in to comment.