Uh oh!
There was an error while loading. Please reload this page.
fix: outside import with relative module graph - #3417
Conversation
jumski
commented
Apr 10, 2025
Yes please! This makes the outside imports usable 🎉 |
laktek
left a comment
There was a problem hiding this comment.
Thanks! This applies to local development as in functions serve right?
@sweatybridge and CLI team will review & merge it.
Uh oh!
There was an error while loading. Please reload this page.
77b2976 to
861580dComparekallebysantos
commented
Apr 10, 2025
Yes, it will bind the missing files to the docker container |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
It applies the import map walking to resolve the Module Graph
Moving `ImportMap` struct to `functions/pkg` and importing it inside internals
0ace083 to
7f0ae8fCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- we don't need to tee here, just copy from file to the writer will do.
- using `afero.NewIOFS(fsys)` to cast to `io.FS`
- Convert `srcPath` inside `addFile`, since docker mount always expect an absolute path
| } | ||
| // Resolving all Import Graph | ||
| addModule := func(unixPath string, w io.Writer) error { | ||
| hostPath := filepath.FromSlash(unixPath) |
There was a problem hiding this comment.
Hey @sweatybridge I think u did revert the absolute path commitc6da3a7. Was that intentional?
There was a problem hiding this comment.
yea.. actually the implementation of walkImportPaths assumed inputs are relative paths only, for a few reasons.
- api upload doesn't support absolute path as the name of form upload
- we can't get back the absolute path on windows without assuming the drive letter is always the same as cwd
so there are still a bit of touch up / refactoring i need to do after this
There was a problem hiding this comment.
I see, well from my tests except by the supabase/function/slug/index.ts file all others was already returned as fullpath from the walkImportPaths method.
You can see it by printing out the unixPath variable
Uh oh!
There was an error while loading. Please reload this page.
@kallebysantos does this require some special configuration or flags to e: nvm, I had |
kallebysantos
commented
Apr 15, 2025
Hey @wyozi, sorry about that confusion 😅 Working example// supabase/functions/[slug]/deno.json
{
"imports": {
"@mylib": "../../../my-lib/index.ts"
}
} |
wyozi
commented
Apr 15, 2025
@kallebysantos ah yeah, good stuff. I think that feature actually already is in 2.22.1, which is why just removing the |
What kind of change does this PR introduce?
Bug fix
What is the current behavior?
When using
outside importfor local development, the bundler does not include relative imports in the Module graph,Like the following example
Error
What is the new behavior?
This PR applies the same
import resolutionas when deploying from--use-api. So it ensures that all files are bundled for local development.Fixed