-
Notifications
You must be signed in to change notification settings - Fork 122
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
Consider support for local requires in server.js #340
Comments
There were a couple of reasons for doing this a while ago but I agree that's not an issue anymore. We use webpack here for doing this - I would vote 👍 for putting this into the CLI and leaving to webpack to produce the bundled server.js. I think this would be the easiest way to achieve this as we wouldn't change anything on the publishing and execution, only thing would be to add the extra magic to the CLI. |
Ah, there are other options apart from webpack obviously, we may do a spike to see what's the best way to do this :) |
Yeah I would have suggested webpack too! |
Also, @antwhite worked on this a while ago. I think we just may need to bring this code into the cli and add some testing: https://github.com/antwhite/oc-webpack |
@matthewdavidson @matteofigus I like the idea of relying on a bundler + transpiler to solve this and #339
|
@matteofigus I've had a look at @antwhite's example - it's exactly the approach I mentioned above:
I'd like to have a go at a PR for a webpack solution if thats ok? @nickbalestra, I'd heard of rollup before due to its tree-shaking ability but as far as I am aware it's not widely adopted or at least it's not as ubiquitous as webpack. Webpack 2 has tree shaking and will be stable very soon. I've never heard of bublé - I thought babel was the de-facto standard for compilation 🤔 . Either way i'd err on the side of webpack/babel just because I would feel confident in their future development / support / communities. |
@nickbalestra also relevant since you mention it in your comment on #341. create-react-app uses webpack & babel under the hood. Seeing as it's facebooks officially supported way of getting started with react i'd say they are a safe bet 😇 - although I do appreciate that this particular issue isn't related to front end framework choices in oc components themselves. |
Very good points here. I think I would probably like to see both and then make a decision. Still, don't want to waste anyone's time for working on something that then gets thrown away. My 2 cents, for me most important things are (for both bundler - webpack vs rollup - and transpiler - babel vs buble')
|
Good points!
then imho rollup/bublé just do the job. But If we believe we need/want more powers then I agree that webpack/babel is the way. @matteofigus as per your points 1&4 I would say webpack/babel (both are more mature/battle-tested and have a huge community/plugins/you-name-it. @matthewdavidson I'll be working on it this week and I would love your code-reviews / input / feedback as we move forward, so I guess we could work together on this. About the |
@nickbalestra in relation to the watcher I think it's almost as the opposite. OC has its own watcher during dev, once there is a change there is a "build" process that currently (re)generates the I think we need to get rid of the require stuff (webpack takes care of it) and then add the babelification too. We can pair on this tomorrow ;) |
Yup that's it. Let's do it :) |
@nickbalestra Awesome, count me in for reviews etc. |
@matteofigus, @matthewdavidson Tests are obviously broken at the moment, and the webpack config/build is far from production-grade. I've also removed for the moment the various things we were doing 'manually' like checking dependencies as I believe we should be able to get those from webpack. Please let me know what you think about this very early concept. |
Done with #346 |
Just ran into this ...
Packaging components...an error happened while packaging /path/to/my/component: ./path/to/local/module.json not found. Only json files are require-able.
I get the design decision of limiting local requires to
.json
files - keeping server.js small and limiting it's responsibility to component data fetching / plumbing 👍 .However, the existence of a hard limitation in the framework seems a little too restrictive IMHO:
server.js
(in doing so bundle all of their local requires into one file)My particular use case is as follows (React server side rendering):
Are there any major objections to this? Potential downsides I see are CLI bloat and percieved lack of control over
server.js
complexity. CLI bloat because we'd probably need some sort of module bundler to allow local requires. That being said we've discussed similar stuff in #339. And in terms of lack of control .... surely thats what code reviews are for 😇 .The text was updated successfully, but these errors were encountered: