-
Notifications
You must be signed in to change notification settings - Fork 421
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
Improve compatibility with webpack #4170
Comments
Hey @chasenlehara! I'm happy to help you. I've created the webpack loader some time ago for one of the projects I was involved in the past. If you feel you would like to contribute to the project or even take an ownership of it I could grant you all needed accesses. |
@chasenlehara Ours has support for extracting and processing nested (As an aside: It's quite tricky to get this working with webpack's interpretation of Ours also generates webpack-compatible source maps and handles them quite nicely: It creates a sub-folder for each If you're interested, we could probably donate the code. Would have to double-check with management, but since it's not exactly core business related material, it'll probably be fine. |
As part of this issue, we will need to make sure the build actually works. I think we are currently testing the build. We will need to test this fashion of build too. Should we do this for both 4.X and 5.X? |
I created a smoke test that has a basic app that's built with webpack. It's here: https://github.com/canjs/canjs/tree/major/test/builders/webpack Ideally we would run all of the canjs tests through webpack, but many of them depend on steal. |
I started working on |
Quickly tossed together a repository that holds an export of our current code. Feel free to have a look. |
@chasenlehara when you said |
What I had in mind was making sure I’m not exactly sure what a test for this should look like… maybe it would require building a bundle with webpack? Maybe this is already covered by the tests @matthewp added for #4200 or #4133? |
Should we write tests that check that warning and debug messages ar e not displayed in the production builds? |
I think we should have a "webpack-test" module that imports all the tests that are "safe" for webpack to run. Then we should have webpack build those tests and run the built version. By "safe", I mean tests that are not using |
Currently there are probably no safe modules, given that all of the canjs tests use |
FYI; the resolution taken to that issue runs counter towards common practice. Misunderstandings usually stem from people confusing A correct "works everywhere" set-up is the following:
Many bundlers including Webpack can pick their compile target, switching between e.g. Finally, in the case of modern bundlers that understand ES6 modules and can perform tree-shaking, you'll want a build that transpiles everything down to ES5, except the ES6 import statements. You can put that in Up-to-date bundlers like Rollup and Webpack should respect that property as well. |
@rjgotten There's nothing that needs to be transpiled in canjs packages. The |
@matthewp can you please tell me what do you mean by "clone"? write the same tests for webpack? |
I mean that you would need to write a webpack plugin (which I don't know how to do) that makes it possible to include steal-qunit, since all of our tests use steal-qunit. I would probably wait on doing this. It would be quite a task. I would just focus on adding the |
@matthewp thank you, that's what I'm doing now, I just want to have some ideas on how tests could be written. |
@cherifGsoul @chasenlehara can this be closed? |
We need |
@phillipskevin this what should be closed for fixning dev mode! |
@macku Would you mind transferring your project to the |
@matthewp I reached out to him over email. 😊 |
@matthewp @chasenlehara I've granted you a permission to the NPM package. Let me check what I can do with github repo. |
TLDR: improve webpack compatibility by making sure debug code gets removed in production builds, contributing to a webpack loader for stache templates, and adding tests for loading our modules.
There are three main problems with using CanJS & webpack right now. This proposal is to fix all three issues.
Debug code is left in production builds
This problem & its solution is covered in Make CanJS compatible with how webpack strips out dev code.
Loading stache templates is unintuitive
In our docs for setting up CanJS & webpack, we encourage people to install the raw-loader and use it like so:
Instead, I propose that we contribute to can-stache-loader and show it in our guides. That package currently supports CanJS 2.3 and has a pre-release with 3.x support; I propose that we contribute 4.x compatibility and help maintain it in the future.
If @macku doesn’t want our help maintaining the project (I hope you do Maciej!), then we can create our own package to accomplish the same goals.
We should also update our setting up CanJS & webpack docs to show the loader; this should include updating our webpack-example repo. Additionally, we should submit a PR to include the loader in the webpack Loaders docs.
Sometimes our modules can’t be loaded by webpack
Every once in a while, we make mistakes that work fine with StealJS but not with webpack.
To help catch these mistakes sooner, I propose that we add tests to the main CanJS test suite that load all the modules with webpack. At a minimum, this would help us ensure that everything can be imported/required.
Alternatively, we could do this in each package and run the test suite to make sure everything works as expected, but I think this would be too much of a maintenance burden for too little reward.
The text was updated successfully, but these errors were encountered: