Skip to content

Commit

Permalink
fix: alias @proscenium/stimulus-loading
Browse files Browse the repository at this point in the history
  • Loading branch information
joelmoss committed Jan 4, 2025
1 parent 45fe13d commit c29d020
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ GEM
racc (~> 1.4)
nokogiri (1.17.2-x86_64-linux)
racc (~> 1.4)
oj (3.16.8)
oj (3.16.9)
bigdecimal (>= 3.0)
ostruct (>= 0.2)
ostruct (0.6.1)
Expand Down
6 changes: 6 additions & 0 deletions internal/plugin/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ var Ui = esbuild.Plugin{
return resolvePath(args)
})

build.OnResolve(esbuild.OnResolveOptions{Filter: `^@proscenium/stimulus-loading`},
func(args esbuild.OnResolveArgs) (esbuild.OnResolveResult, error) {
args.Path = strings.TrimPrefix(args.Path, "@proscenium/")
return resolvePath(args)
})

build.OnResolve(esbuild.OnResolveOptions{Filter: `^@proscenium/`},
func(args esbuild.OnResolveArgs) (esbuild.OnResolveResult, error) {
args.Path = strings.TrimPrefix(args.Path, "@proscenium/ui")
Expand Down
12 changes: 12 additions & 0 deletions test/ui_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ var _ = Describe("b.Build(ui)", func() {
`))
})

It("resolves @proscenium/stimulus-loading", func() {
Expect(b.Build("@proscenium/stimulus-loading")).To(ContainCode(`
function lazyLoadControllersFrom
`))
})

It("resolves imports", func() {
Expect(b.Build("@proscenium/ujs/class.js")).To(ContainCode(`
import DataConfirm from "/proscenium/ui/ujs/data_confirm.js";
Expand Down Expand Up @@ -77,5 +83,11 @@ var _ = Describe("b.Build(ui)", func() {
console.log("@proscenium/ui/test.js");
`))
})

It("resolves @proscenium/stimulus-loading", func() {
Expect(b.Build("@proscenium/stimulus-loading")).To(ContainCode(`
function lazyLoadControllersFrom
`))
})
})
})

0 comments on commit c29d020

Please sign in to comment.