Skip to content

Commit

Permalink
chore(deps): update dependency import-meta-resolve to v4 (#16086)
Browse files Browse the repository at this point in the history
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Babel Bot <30521560+liuxingbaoyu@users.noreply.github.com>
  • Loading branch information
renovate[bot] and liuxingbaoyu committed Nov 22, 2023
1 parent fadc081 commit cf53966
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"gulp-filter": "^7.0.0",
"gulp-plumber": "^1.2.1",
"husky": "^8.0.3",
"import-meta-resolve": "^3.0.0",
"import-meta-resolve": "^4.0.0",
"is-ci": "^3.0.1",
"jest": "^30.0.0-alpha.1",
"jest-light-runner": "^0.6.0-alpha.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-code-frame/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"chalk": "condition:BABEL_8_BREAKING ? ^5.3.0 : ^2.4.2 (esm:default|Chalk)"
},
"devDependencies": {
"import-meta-resolve": "^3.0.0",
"import-meta-resolve": "^4.0.0",
"strip-ansi": "^4.0.0"
},
"engines": {
Expand Down
11 changes: 10 additions & 1 deletion packages/babel-core/src/config/files/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { fileURLToPath, pathToFileURL } from "url";
import { resolve as importMetaResolve } from "../../vendor/import-meta-resolve.js";

import { createRequire } from "module";
import { existsSync } from "fs";
const require = createRequire(import.meta.url);

const debug = buildDebug("babel:config:loading:files:plugins");
Expand Down Expand Up @@ -196,7 +197,15 @@ function resolveStandardizedName(
}

try {
return resolveStandardizedNameForImport(type, name, dirname);
const resolved = resolveStandardizedNameForImport(type, name, dirname);
// import-meta-resolve 4.0 does not throw if the module is not found.
if (!existsSync(resolved)) {
throw Object.assign(
new Error(`Could not resolve "${name}" in file ${dirname}.`),
{ type: "MODULE_NOT_FOUND" },
);
}
return resolved;
} catch (e) {
try {
return resolveStandardizedNameForRequire(type, name, dirname);
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ __metadata:
dependencies:
"@babel/highlight": "workspace:^"
chalk: "condition:BABEL_8_BREAKING ? ^5.3.0 : ^2.4.2 (esm:default|Chalk)"
import-meta-resolve: "npm:^3.0.0"
import-meta-resolve: "npm:^4.0.0"
strip-ansi: "npm:^4.0.0"
languageName: unknown
linkType: soft
Expand Down Expand Up @@ -6808,7 +6808,7 @@ __metadata:
gulp-filter: "npm:^7.0.0"
gulp-plumber: "npm:^1.2.1"
husky: "npm:^8.0.3"
import-meta-resolve: "npm:^3.0.0"
import-meta-resolve: "npm:^4.0.0"
is-ci: "npm:^3.0.1"
jest: "npm:^30.0.0-alpha.1"
jest-light-runner: "npm:^0.6.0-alpha.1"
Expand Down Expand Up @@ -10626,10 +10626,10 @@ __metadata:
languageName: node
linkType: hard

"import-meta-resolve@npm:^3.0.0":
version: 3.0.0
resolution: "import-meta-resolve@npm:3.0.0"
checksum: f50697d21c5e4ed00425fc756a84deaf8911954786ce1639874ed6e85565bbecda738dc7554f56f70594bca5c6d67cb329912f97adf4288d216e143f07d6af43
"import-meta-resolve@npm:^4.0.0":
version: 4.0.0
resolution: "import-meta-resolve@npm:4.0.0"
checksum: 73f0f1d68f7280cb4415e3a212a6e5d57fbfe61ab6f467df3dad5361529fbd89ac7d8ea2b694412b74985a4226d218ad3fb22fd8f06f5429beda521dc9f0229c
languageName: node
linkType: hard

Expand Down

0 comments on commit cf53966

Please sign in to comment.