-
Notifications
You must be signed in to change notification settings - Fork 122
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
import.meta.resolve for files #1696
Conversation
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.
in preview, this does not seem to apply to "volcano.json"
without a leading ./
:
FileAttachment("volcano.json").href // "http://127.0.0.1:3000/_file/volcano.json?sha=f5223ec98032634f121adef600c947fab5ab9389d689a0bb1e21d6a877d21178"
import.meta.resolve("volcano.json") // "volcano.json" 🌶
import.meta.resolve("./volcano.json") // "http://127.0.0.1:3000/_file/volcano.json?sha=f5223ec98032634f121adef600c947fab5ab9389d689a0bb1e21d6a877d21178"
and in build, it crashes on import.meta.resolve("./volcano.json")
:
copy docs/volcano.json →
Unexpected error: Unexpected token (1:8)
The full error follows
file:///Users/fil/Source/framework/node_modules/acorn/dist/acorn.mjs:3580
var err = new SyntaxError(message);
^
Also, can we mention it in docs/files.md
?
The error is expected. You need to using a leading dot-slash to import a relative path ( |
This comment was marked as resolved.
This comment was marked as resolved.
I think I'm seeing a different bug, as I get a crash (
to However it doesn't seem completely related to this PR, or it's my testing that is wrong, because I see the same issue on main with this minimal repro: https://github.com/observablehq/broken-build/blob/main/src/index.md (I'm a bit puzzled.) |
I’m able to reproduce the error, thanks. Investigating now. |
Okay, fixed. 👍 |
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.
I guess it's missing documentation, but LGTM
oops auto-merge |
Fixes #1008. When
import.meta.resolve
is passed a relative path to a non-JavaScript file (anything other than.js
,.mjs
, or.cjs
— and the latter two we don’t expect in practice), it now usesresolveFile
instead ofresolveImport
to resolve.