-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix import-meta-asset-plugin resolution
- Loading branch information
Loïc Mangeonjean
committed
Oct 7, 2024
1 parent
0751bc9
commit 4460d21
Showing
2 changed files
with
28 additions
and
7 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,25 @@ | ||
diff --git a/node_modules/@web/rollup-plugin-import-meta-assets/src/rollup-plugin-import-meta-assets.js b/node_modules/@web/rollup-plugin-import-meta-assets/src/rollup-plugin-import-meta-assets.js | ||
index 245ec98..d623ef3 100644 | ||
--- a/node_modules/@web/rollup-plugin-import-meta-assets/src/rollup-plugin-import-meta-assets.js | ||
+++ b/node_modules/@web/rollup-plugin-import-meta-assets/src/rollup-plugin-import-meta-assets.js | ||
@@ -161,11 +161,19 @@ ${` default: return new Promise(function(resolve, reject) { | ||
if (importMetaUrlType === 'static') { | ||
const absoluteScriptDir = path.dirname(id); | ||
const relativeAssetPath = getRelativeAssetPath(node); | ||
+ const resolved = await this.resolve(relativeAssetPath, id) | ||
+ if (resolved == null) { | ||
+ this.error(`Unable to resolve "${relativeAssetPath}" from "${id}"`) | ||
+ return | ||
+ } | ||
+ if (resolved.external) { | ||
+ return | ||
+ } | ||
const absoluteAssetPath = path.resolve(absoluteScriptDir, relativeAssetPath); | ||
const assetName = path.basename(absoluteAssetPath); | ||
|
||
try { | ||
- const assetContents = await fs.promises.readFile(absoluteAssetPath); | ||
+ const assetContents = await fs.promises.readFile(resolved.id); | ||
const transformedAssetContents = | ||
transform != null | ||
? await transform(assetContents, absoluteAssetPath) |
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