analogjs / analog

The fullstack meta-framework for Angular. Powered by Vite and Nitro
https://analogjs.org
MIT License
2.5k stars 240 forks source link

[FEAT]: Add support for passing environment providers to Angular components used in Astro #97

Closed brandonroberts closed 1 year ago

brandonroberts commented 1 year ago

Which scope/s are relevant/related to the feature request?

astro-angular

Information

Currently, you can only use component-level providers, and do not have access to pass environment-level providers when rendering on the server or hydrating on the client.

Describe any alternatives/workarounds you're currently using

No response

I would be willing to submit a PR to fix this issue

himyjan commented 1 year ago

@analogjs/astro-angular with @example/framework-multiple log tsx error test repo after add "include": ["src/**/*.ts", "src/**/*.tsx"] to tsconfig.app.json

❯ npm run dev

> @example/framework-multiple@0.0.1 dev
> astro dev

  🚀  astro  v1.4.2 started in 4655ms

  ┃ Local    http://127.0.0.1:3000/
  ┃ Network  use --host to expose

Sourcemap for "/Users/user/Desktop/Astro/node_modules/@analogjs/astro-angular/src/server.js" points to missing source files
Angular is running in development mode. Call enableProdMode() to enable production mode.
 error   Unable to render react.Counter because it is undefined!
  Did you forget to import the component or is it possible there is a typo?
Error: Unable to render react.Counter because it is undefined!
Did you forget to import the component or is it possible there is a typo?
    at Module.renderComponent (/node_modules/astro/dist/runtime/server/render/component.js:68:11)
/node_modules/astro/dist/runtime/server/render/component.js:74
    throw new Error(
          ^

Error: Unable to render PreactCounter because it is undefined!
Did you forget to import the component or is it possible there is a typo?
    at Module.renderComponent (/node_modules/astro/dist/runtime/server/render/component.js:74:11)
fatal error: all goroutines are asleep - deadlock!

goroutine 1 [semacquire]:
sync.runtime_Semacquire(0x140000021a0?)
        runtime/sema.go:62 +0x28
sync.(*WaitGroup).Wait(0x140001222d8)
        sync/waitgroup.go:139 +0x80
main.runService(0x1)
        github.com/evanw/esbuild/cmd/esbuild/service.go:177 +0x3e0
main.main()
        github.com/evanw/esbuild/cmd/esbuild/main.go:231 +0x1b0

goroutine 18 [chan receive]:
main.runService.func1()
        github.com/evanw/esbuild/cmd/esbuild/service.go:110 +0x4c
created by main.runService
        github.com/evanw/esbuild/cmd/esbuild/service.go:108 +0x14c

goroutine 19 [chan receive]:
main.(*serviceType).sendRequest(0x140001222c0, {0x10103baa0, 0x14000a2ae10})
        github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8
main.runService.func2()
        github.com/evanw/esbuild/cmd/esbuild/service.go:132 +0x38
created by main.runService
        github.com/evanw/esbuild/cmd/esbuild/service.go:129 +0x264

goroutine 202 [chan receive]:
github.com/evanw/esbuild/internal/bundler.(*scanner).scanAllDependencies(0x140004b3000)
        github.com/evanw/esbuild/internal/bundler/bundler.go:1687 +0x198
github.com/evanw/esbuild/internal/bundler.ScanBundle({_, _, _, _, _, _}, {_, _}, {_, _}, ...)
        github.com/evanw/esbuild/internal/bundler/bundler.go:1159 +0x5a4
github.com/evanw/esbuild/pkg/api.rebuildImpl({0x2, 0x5, 0x0, 0x1400081c8d0, 0x2, {0x0, 0x0}, 0x0, 0x8, {0x0, ...}, ...}, ...)
        github.com/evanw/esbuild/pkg/api/api_impl.go:1067 +0x16a0
github.com/evanw/esbuild/pkg/api.buildImpl({0x2, 0x5, 0x0, 0x1400081c8d0, 0x2, {0x0, 0x0}, 0x0, 0x8, {0x0, ...}, ...})
        github.com/evanw/esbuild/pkg/api/api_impl.go:799 +0x46c
github.com/evanw/esbuild/pkg/api.Build(...)
        github.com/evanw/esbuild/pkg/api/api.go:365
main.(*serviceType).handleBuildRequest(0x140001222c0, 0x81c510?, 0x100f1546b?)
        github.com/evanw/esbuild/cmd/esbuild/service.go:501 +0x7e4
main.(*serviceType).handleIncomingPacket(0x0?, {0x140001a8000?, 0x104032c01ff81?, 0x0?})
        github.com/evanw/esbuild/cmd/esbuild/service.go:232 +0x124
main.runService.func3()
        github.com/evanw/esbuild/cmd/esbuild/service.go:163 +0x30
created by main.runService
        github.com/evanw/esbuild/cmd/esbuild/service.go:162 +0x3f4

goroutine 106 [chan receive]:
main.(*serviceType).sendRequest(0x140001222c0, {0x10103baa0, 0x140017769f0})
        github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8
main.(*serviceType).convertPlugins.func2.4({{0x140002b2c30, 0x48}, {0x100f13dc2, 0x4}, {0x0, 0x0}, {0x0, 0x0}})
        github.com/evanw/esbuild/cmd/esbuild/service.go:860 +0x3b0
github.com/evanw/esbuild/pkg/api.(*pluginImpl).onLoad.func1({{0x0, 0x0}, {{0x140002b2c30, 0x48}, {0x100f13dc2, 0x4}, {0x0, 0x0}, 0x0}})
        github.com/evanw/esbuild/pkg/api/api_impl.go:1682 +0xe4
github.com/evanw/esbuild/internal/bundler.runOnLoadPlugins({0x14000758600?, 0x1, 0x0?}, {0x1010a6098, 0x140004b2800}, {0x1010a81d8, 0x14000414de0?}, 0x288?, {0x140003416c0, 0x140005f23d8, ...}, ...)
        github.com/evanw/esbuild/internal/bundler/bundler.go:880 +0xa0c
github.com/evanw/esbuild/internal/bundler.parseFile({{0x1010a81d8, 0x14000414de0}, {0x140003416c0, 0x140005f23d8, 0x140005f23f0, 0x14000414da0, 0x5, 0x1400081cba0}, {0x1010a6098, 0x140004b2800}, ...})
        github.com/evanw/esbuild/internal/bundler/bundler.go:129 +0x178
created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile
        github.com/evanw/esbuild/internal/bundler/bundler.go:1283 +0x6f4

goroutine 407 [chan receive]:
main.(*serviceType).sendRequest(0x140001222c0, {0x10103baa0, 0x140025ebf20})
        github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8
main.(*serviceType).convertPlugins.func2.4({{0x1400012d780, 0x39}, {0x100f13dc2, 0x4}, {0x0, 0x0}, {0x0, 0x0}})
        github.com/evanw/esbuild/cmd/esbuild/service.go:860 +0x3b0
github.com/evanw/esbuild/pkg/api.(*pluginImpl).onLoad.func1({{0x0, 0x0}, {{0x1400012d780, 0x39}, {0x100f13dc2, 0x4}, {0x0, 0x0}, 0x0}})
        github.com/evanw/esbuild/pkg/api/api_impl.go:1682 +0xe4
github.com/evanw/esbuild/internal/bundler.runOnLoadPlugins({0x14000758600?, 0x1, 0x140007c4460?}, {0x1010a6098, 0x140004b2800}, {0x1010a81d8, 0x14000414de0?}, 0x0?, {0x140003416c0, 0x140005f23d8, ...}, ...)
        github.com/evanw/esbuild/internal/bundler/bundler.go:880 +0xa0c
github.com/evanw/esbuild/internal/bundler.parseFile({{0x1010a81d8, 0x14000414de0}, {0x140003416c0, 0x140005f23d8, 0x140005f23f0, 0x14000414da0, 0x5, 0x1400081cba0}, {0x1010a6098, 0x140004b2800}, ...})
        github.com/evanw/esbuild/internal/bundler/bundler.go:129 +0x178
created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile
        github.com/evanw/esbuild/internal/bundler/bundler.go:1283 +0x6f4

goroutine 475 [chan receive]:
main.(*serviceType).sendRequest(0x140001222c0, {0x10103baa0, 0x14000f4ed20})
        github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8
main.(*serviceType).convertPlugins.func2.4({{0x1400002f090, 0x4d}, {0x100f13dc2, 0x4}, {0x0, 0x0}, {0x0, 0x0}})
        github.com/evanw/esbuild/cmd/esbuild/service.go:860 +0x3b0
github.com/evanw/esbuild/pkg/api.(*pluginImpl).onLoad.func1({{0x0, 0x0}, {{0x1400002f090, 0x4d}, {0x100f13dc2, 0x4}, {0x0, 0x0}, 0x0}})
        github.com/evanw/esbuild/pkg/api/api_impl.go:1682 +0xe4
github.com/evanw/esbuild/internal/bundler.runOnLoadPlugins({0x14000758600?, 0x1, 0x140001d84b0?}, {0x1010a6098, 0x140004b2800}, {0x1010a81d8, 0x14000414de0?}, 0x0?, {0x140003416c0, 0x140005f23d8, ...}, ...)
        github.com/evanw/esbuild/internal/bundler/bundler.go:880 +0xa0c
github.com/evanw/esbuild/internal/bundler.parseFile({{0x1010a81d8, 0x14000414de0}, {0x140003416c0, 0x140005f23d8, 0x140005f23f0, 0x14000414da0, 0x5, 0x1400081cba0}, {0x1010a6098, 0x140004b2800}, ...})
        github.com/evanw/esbuild/internal/bundler/bundler.go:129 +0x178
created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile
        github.com/evanw/esbuild/internal/bundler/bundler.go:1283 +0x6f4

goroutine 103 [chan receive]:
main.(*serviceType).sendRequest(0x140001222c0, {0x10103baa0, 0x1400164d5c0})
        github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8
main.(*serviceType).convertPlugins.func2.4({{0x14001a961c0, 0x3a}, {0x100f13dc2, 0x4}, {0x0, 0x0}, {0x0, 0x0}})
        github.com/evanw/esbuild/cmd/esbuild/service.go:860 +0x3b0
github.com/evanw/esbuild/pkg/api.(*pluginImpl).onLoad.func1({{0x0, 0x0}, {{0x14001a961c0, 0x3a}, {0x100f13dc2, 0x4}, {0x0, 0x0}, 0x0}})
        github.com/evanw/esbuild/pkg/api/api_impl.go:1682 +0xe4
github.com/evanw/esbuild/internal/bundler.runOnLoadPlugins({0x14000758600?, 0x1, 0x140001d9770?}, {0x1010a6098, 0x140004b2800}, {0x1010a81d8, 0x14000414de0?}, 0x0?, {0x140003416c0, 0x140005f23d8, ...}, ...)
        github.com/evanw/esbuild/internal/bundler/bundler.go:880 +0xa0c
github.com/evanw/esbuild/internal/bundler.parseFile({{0x1010a81d8, 0x14000414de0}, {0x140003416c0, 0x140005f23d8, 0x140005f23f0, 0x14000414da0, 0x5, 0x1400081cba0}, {0x1010a6098, 0x140004b2800}, ...})
        github.com/evanw/esbuild/internal/bundler/bundler.go:129 +0x178
created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile
        github.com/evanw/esbuild/internal/bundler/bundler.go:1283 +0x6f4

goroutine 473 [chan receive]:
main.(*serviceType).sendRequest(0x140001222c0, {0x10103baa0, 0x14000f4eb10})
        github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8
main.(*serviceType).convertPlugins.func2.4({{0x14001a1a0f0, 0x4a}, {0x100f13dc2, 0x4}, {0x0, 0x0}, {0x0, 0x0}})
        github.com/evanw/esbuild/cmd/esbuild/service.go:860 +0x3b0
github.com/evanw/esbuild/pkg/api.(*pluginImpl).onLoad.func1({{0x0, 0x0}, {{0x14001a1a0f0, 0x4a}, {0x100f13dc2, 0x4}, {0x0, 0x0}, 0x0}})
        github.com/evanw/esbuild/pkg/api/api_impl.go:1682 +0xe4
github.com/evanw/esbuild/internal/bundler.runOnLoadPlugins({0x14000758600?, 0x1, 0x14001256240?}, {0x1010a6098, 0x140004b2800}, {0x1010a81d8, 0x14000414de0?}, 0x0?, {0x140003416c0, 0x140005f23d8, ...}, ...)
        github.com/evanw/esbuild/internal/bundler/bundler.go:880 +0xa0c
github.com/evanw/esbuild/internal/bundler.parseFile({{0x1010a81d8, 0x14000414de0}, {0x140003416c0, 0x140005f23d8, 0x140005f23f0, 0x14000414da0, 0x5, 0x1400081cba0}, {0x1010a6098, 0x140004b2800}, ...})
        github.com/evanw/esbuild/internal/bundler/bundler.go:129 +0x178
created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile
        github.com/evanw/esbuild/internal/bundler/bundler.go:1283 +0x6f4

goroutine 392 [chan receive]:
main.(*serviceType).sendRequest(0x140001222c0, {0x10103baa0, 0x14001f72450})
        github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8
main.(*serviceType).convertPlugins.func2.4({{0x1400050e280, 0x3b}, {0x100f13dc2, 0x4}, {0x0, 0x0}, {0x0, 0x0}})
        github.com/evanw/esbuild/cmd/esbuild/service.go:860 +0x3b0
github.com/evanw/esbuild/pkg/api.(*pluginImpl).onLoad.func1({{0x0, 0x0}, {{0x1400050e280, 0x3b}, {0x100f13dc2, 0x4}, {0x0, 0x0}, 0x0}})
        github.com/evanw/esbuild/pkg/api/api_impl.go:1682 +0xe4
github.com/evanw/esbuild/internal/bundler.runOnLoadPlugins({0x14000758600?, 0x1, 0x0?}, {0x1010a6098, 0x140004b2800}, {0x1010a81d8, 0x14000414de0?}, 0x288?, {0x140003416c0, 0x140005f23d8, ...}, ...)
        github.com/evanw/esbuild/internal/bundler/bundler.go:880 +0xa0c
github.com/evanw/esbuild/internal/bundler.parseFile({{0x1010a81d8, 0x14000414de0}, {0x140003416c0, 0x140005f23d8, 0x140005f23f0, 0x14000414da0, 0x5, 0x1400081cba0}, {0x1010a6098, 0x140004b2800}, ...})
        github.com/evanw/esbuild/internal/bundler/bundler.go:129 +0x178
created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile
        github.com/evanw/esbuild/internal/bundler/bundler.go:1283 +0x6f4

goroutine 105 [chan receive]:
main.(*serviceType).sendRequest(0x140001222c0, {0x10103baa0, 0x14001776a20})
        github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8
main.(*serviceType).convertPlugins.func2.4({{0x1400012c9c0, 0x3e}, {0x100f13dc2, 0x4}, {0x0, 0x0}, {0x0, 0x0}})
        github.com/evanw/esbuild/cmd/esbuild/service.go:860 +0x3b0
github.com/evanw/esbuild/pkg/api.(*pluginImpl).onLoad.func1({{0x0, 0x0}, {{0x1400012c9c0, 0x3e}, {0x100f13dc2, 0x4}, {0x0, 0x0}, 0x0}})
        github.com/evanw/esbuild/pkg/api/api_impl.go:1682 +0xe4
github.com/evanw/esbuild/internal/bundler.runOnLoadPlugins({0x14000758600?, 0x1, 0x0?}, {0x1010a6098, 0x140004b2800}, {0x1010a81d8, 0x14000414de0?}, 0x0?, {0x140003416c0, 0x140005f23d8, ...}, ...)
        github.com/evanw/esbuild/internal/bundler/bundler.go:880 +0xa0c
github.com/evanw/esbuild/internal/bundler.parseFile({{0x1010a81d8, 0x14000414de0}, {0x140003416c0, 0x140005f23d8, 0x140005f23f0, 0x14000414da0, 0x5, 0x1400081cba0}, {0x1010a6098, 0x140004b2800}, ...})
        github.com/evanw/esbuild/internal/bundler/bundler.go:129 +0x178
created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile
        github.com/evanw/esbuild/internal/bundler/bundler.go:1283 +0x6f4

goroutine 459 [chan receive]:
main.(*serviceType).sendRequest(0x140001222c0, {0x10103baa0, 0x140021ae060})
        github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8
main.(*serviceType).convertPlugins.func2.3({{0x140025b60f0, 0xf}, {0x140007c4460, 0x48}, {0x100f13dc2, 0x4}, {0x140007c4460, _}, _, {_, ...}})
        github.com/evanw/esbuild/cmd/esbuild/service.go:781 +0x550
github.com/evanw/esbuild/pkg/api.(*pluginImpl).onResolve.func1({{0x140025b60f0, 0xf}, {0x140007c4460, 0x38}, {0x0, 0x0}, {{0x140007c4460, _}, {_, _}, ...}, ...})
        github.com/evanw/esbuild/pkg/api/api_impl.go:1627 +0x194
github.com/evanw/esbuild/internal/bundler.RunOnResolvePlugins({0x14000758600?, 0x1, 0x1?}, {0x1010a6098, 0x140004b2800}, {0x140003416c0, 0x140005f23d8, 0x140005f23f0, 0x14000414da0, 0x5, ...}, ...)
        github.com/evanw/esbuild/internal/bundler/bundler.go:763 +0x64c
github.com/evanw/esbuild/internal/bundler.parseFile({{0x1010a81d8, 0x14000414de0}, {0x140003416c0, 0x140005f23d8, 0x140005f23f0, 0x14000414da0, 0x5, 0x1400081cba0}, {0x1010a6098, 0x140004b2800}, ...})
        github.com/evanw/esbuild/internal/bundler/bundler.go:407 +0x1d9c
created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile
        github.com/evanw/esbuild/internal/bundler/bundler.go:1283 +0x6f4

goroutine 474 [chan receive]:
main.(*serviceType).sendRequest(0x140001222c0, {0x10103baa0, 0x140021ae000})
        github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8
main.(*serviceType).convertPlugins.func2.4({{0x140012563c0, 0x59}, {0x100f13dc2, 0x4}, {0x0, 0x0}, {0x0, 0x0}})
        github.com/evanw/esbuild/cmd/esbuild/service.go:860 +0x3b0
github.com/evanw/esbuild/pkg/api.(*pluginImpl).onLoad.func1({{0x0, 0x0}, {{0x140012563c0, 0x59}, {0x100f13dc2, 0x4}, {0x0, 0x0}, 0x0}})
        github.com/evanw/esbuild/pkg/api/api_impl.go:1682 +0xe4
github.com/evanw/esbuild/internal/bundler.runOnLoadPlugins({0x14000758600?, 0x1, 0x140001d8910?}, {0x1010a6098, 0x140004b2800}, {0x1010a81d8, 0x14000414de0?}, 0x0?, {0x140003416c0, 0x140005f23d8, ...}, ...)
        github.com/evanw/esbuild/internal/bundler/bundler.go:880 +0xa0c
github.com/evanw/esbuild/internal/bundler.parseFile({{0x1010a81d8, 0x14000414de0}, {0x140003416c0, 0x140005f23d8, 0x140005f23f0, 0x14000414da0, 0x5, 0x1400081cba0}, {0x1010a6098, 0x140004b2800}, ...})
        github.com/evanw/esbuild/internal/bundler/bundler.go:129 +0x178
created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile
        github.com/evanw/esbuild/internal/bundler/bundler.go:1283 +0x6f4

goroutine 104 [chan receive]:
main.(*serviceType).sendRequest(0x140001222c0, {0x10103baa0, 0x140025fa7e0})
        github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8
main.(*serviceType).convertPlugins.func2.3({{0x140025ecb80, 0x5}, {0x140002b2b90, 0x44}, {0x100f13dc2, 0x4}, {0x140002b2b90, _}, _, {_, ...}})
        github.com/evanw/esbuild/cmd/esbuild/service.go:781 +0x550
github.com/evanw/esbuild/pkg/api.(*pluginImpl).onResolve.func1({{0x140025ecb80, 0x5}, {0x140002b2b90, 0x35}, {0x0, 0x0}, {{0x140002b2b90, _}, {_, _}, ...}, ...})
        github.com/evanw/esbuild/pkg/api/api_impl.go:1627 +0x194
github.com/evanw/esbuild/internal/bundler.RunOnResolvePlugins({0x14000758600?, 0x1, 0x1?}, {0x1010a6098, 0x140004b2800}, {0x140003416c0, 0x140005f23d8, 0x140005f23f0, 0x14000414da0, 0x5, ...}, ...)
        github.com/evanw/esbuild/internal/bundler/bundler.go:763 +0x64c
github.com/evanw/esbuild/internal/bundler.parseFile({{0x1010a81d8, 0x14000414de0}, {0x140003416c0, 0x140005f23d8, 0x140005f23f0, 0x14000414da0, 0x5, 0x1400081cba0}, {0x1010a6098, 0x140004b2800}, ...})
        github.com/evanw/esbuild/internal/bundler/bundler.go:407 +0x1d9c
created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile
        github.com/evanw/esbuild/internal/bundler/bundler.go:1283 +0x6f4
brandonroberts commented 1 year ago

@himyjan this is not relevant to this issue.

The fix is to add the .tsx files to the includes array of the tsconfig.app.json