Skip to content

Commit

Permalink
fix: include export statements when resolving imports (#3140)
Browse files Browse the repository at this point in the history
  • Loading branch information
sweatybridge authored Feb 13, 2025
1 parent 4b1969f commit e7c11ec
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion internal/functions/deploy/testdata/shared/whatever.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
import * from '../nested/index.ts';
import * as _ from "../nested/index.ts";

export * from "./mod.ts";
2 changes: 1 addition & 1 deletion internal/functions/deploy/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func writeForm(form *multipart.Writer, meta api.FunctionDeployMetadata, fsys afe
}

// Ref: https://regex101.com/r/DfBdJA/1
var importPathPattern = regexp.MustCompile(`(?i)import\s+(?:{[^{}]+}|.*?)\s*(?:from)?\s*['"](.*?)['"]|import\(\s*['"](.*?)['"]\)`)
var importPathPattern = regexp.MustCompile(`(?i)(?:import|export)\s+(?:{[^{}]+}|.*?)\s*(?:from)?\s*['"](.*?)['"]|import\(\s*['"](.*?)['"]\)`)

func walkImportPaths(srcPath string, importMap utils.ImportMap, readFile func(curr string, w io.Writer) error) error {
seen := map[string]struct{}{}
Expand Down
1 change: 1 addition & 0 deletions internal/functions/deploy/upload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func TestImportPaths(t *testing.T) {
fsys.On("ReadFile", "testdata/modules/imports.ts").Once()
fsys.On("ReadFile", "testdata/geometries/Geometries.js").Once()
fsys.On("ReadFile", "testdata/shared/whatever.ts").Once()
fsys.On("ReadFile", "testdata/shared/mod.ts").Once()
fsys.On("ReadFile", "testdata/nested/index.ts").Once()
// Run test
im := utils.ImportMap{Imports: map[string]string{
Expand Down

0 comments on commit e7c11ec

Please sign in to comment.