Skip to content
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

example/protocol_buffers should use ts_project #2381

Closed
simmonmt opened this issue Jan 5, 2021 · 6 comments
Closed

example/protocol_buffers should use ts_project #2381

simmonmt opened this issue Jan 5, 2021 · 6 comments
Assignees

Comments

@simmonmt
Copy link

simmonmt commented Jan 5, 2021

🚀 feature request

Description

example/react_webpack shows how to build a react app using ts_project and webpack. It should also show how to build a react app using ts_library and webpack, as it is my understanding that ts_library is the best way to go if I'm to use dynamically-generated TS files (like protobuf definitions).

I've made an attempt at converting example/app to use ts_library. You can find it here: simmonmt@c2f1fdb

It compiles and bundles properly, but when I load it in the browser (i.e. bazel run :server), I get this error:

app.bundle.js:6 Uncaught Error: Cannot find module 'react'
    at n (app.bundle.js:6)
    at app.bundle.js:6
    at app.bundle.js:6
    at Object.<anonymous> (app.bundle.js:6)
    at n (app.bundle.js:1)
    at app.bundle.js:1
    at app.bundle.js:1

If you can help me to figure out what went wrong here, I'd be happy to submit a PR that adds ts_library to example/react_webpack, thus resolving this issue.

@simmonmt
Copy link
Author

simmonmt commented Jan 6, 2021

I think I found the problem. ts_library by default creates UMD modules in devmode, which isn't compatible with Webpack (or at least not without fancy footwork that's beyond my understanding). Telling it to make es2015 modules makes Webpack happy. PR incoming.

@alexeagle
Copy link
Collaborator

alexeagle commented Jan 25, 2021

could we back up a step? you say

my understanding that ts_library is the best way to go if I'm to use dynamically-generated TS files

I don't think this is true - we'd like to deprecate ts_library. Seems like I should update examples/protocol_buffers to use ts_project instead. Do you remember what you read that gave you that understanding?

@simmonmt
Copy link
Author

#2301, for one, in which it says I'd need to run tsc directly to compile an "opaque" directory of ts files (which confused be, since I thought the proto libraries would be declaring their outputs). Using ts_library seemed a lot easier than that.

@simmonmt
Copy link
Author

And yes, an update to example/protocol_buffers that shows how to use ts_project would be helpful if ts_library isn't the way to go.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had any activity for 90 days. It will be closed if no further activity occurs in two weeks. Collaborators can add a "cleanup" or "need: discussion" label to keep it open indefinitely. Thanks for your contributions to rules_nodejs!

@github-actions github-actions bot added the Can Close? We will close this in 30 days if there is no further activity label May 29, 2021
@alexeagle alexeagle removed the Can Close? We will close this in 30 days if there is no further activity label May 29, 2021
@alexeagle alexeagle self-assigned this May 29, 2021
@alexeagle alexeagle changed the title example/react_webpack should demonstrate ts_library too example/protocol_buffers should use ts_project May 29, 2021
@mattem
Copy link
Collaborator

mattem commented Feb 26, 2022

This was done in 5f26d0f, but has since been removed. Closing as won't fix.

@mattem mattem closed this as completed Feb 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants