-
Notifications
You must be signed in to change notification settings - Fork 194
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
Extract runtime to a separate package and preprocess it with webpack for embedding #42
Comments
Is there any examples you can provide? All code in this repo is written as ES5-compliant as possible (and also in CommonJS), so I don't see it causing trouble in any environments unless you're expecting ES Modules. (I don't know a lot about |
To be more specific, there are numerous issues.
I hope this is enough context - if not - I can create a sample repo. |
This is great - I will work on fixing the issues this week. |
Issue 1 fixed by #58 |
#58 is more of a workaround, however fundamentally the issue is not solved. This can happen again in the future, and there's nothing that would've prevented this. I can help with implementing the bundle split if needed. |
Same goes for #61. @pmmmwh while the particular pain points I stumbled upon are fixed (kudos for that btw), I didn't hear your feedback on the subject of this issue - splitting the runtime (browser end) code and webpack (node end) code into separate packages. Is your point that the code should be portable across the environments, and therefore the split is not required? Well, this might be true, but then I'll end up loading the node-related code in the browser environment and vice versa. This consumes compute cycles unnecessarily, and on its own, it's not a big deal, but coupled with other packages that do the same it becomes a huge problem. Please don't ignore this factor. Anyhow, please reopen this issue, as it has not been addressed entirely. There are other issues, and I'd like to avoid going over them one-by-one. |
Maybe I'm not clear. This project contains the code that runs as part of the webpack build process and the code that runs as part of the compiled resulting bundle. The code that runs in the webpack injects the code that runs at "runtime" into the resulting bundle. |
At this stage I am against splitting the repo into separate packages, I don't think it is any better than the current directory split. Differential compilation on directories is also a way to achieve what you want.
This is not true - code is currently already split into directories.
I don't think this is true either, Node-related files (everything other than
Unless we bundle everything into one file (e.g. Rollup/Webpack), require cycles will still happen, and will only happen with files that are specific to that context. However, most of the runtime code cannot be grouped because of their varying nature, and a lot of the code will not work until it is being injected by
The point is, I don't see any need to pre-process/transpile any of the runtime code. No code in the Unless we're switching to ES Modules/ES6+ syntax, I don't feel that processing the current plain CommonJS, ES5 compliant code (other than use of the |
I'm not following. The issue, in particular, is things like this:
This has nothing to do with polyfilling, but about cutting what gets evaluated in the renderer webpack context or now. You are assuming that only the content of the I don't know why it only affects electron, possibly because there we have all the various execution contexts, while normally the situation would be way simpler. We have:
So, again, if everything worked as you assume - with only |
Steps to reproduce the core issue:
The last Again the
|
UPD: also it comes from the
|
Also, to see how it effectively affects electron apps, add |
I'm getting confused. If you trave the code paths that actually gets into Webpack's That seems like a bug somewhere outside of our control 🤔 even if we separate the runtime package from the plugin, it will not help cause one is injected by the other. For With |
I think you have some wrong assumptions about the problem - I did the exact steps and while For |
Weren’t you able to reproduce it with my example? I can create an example project and upload it to github. UPD: ah, I see, indeed |
Huh, so it’s simply not supposed to be an external import, but a import from the |
One possible fix for this, I think, is for the runtime code to assume the |
It would be a good idea to allow removing the code that does this check from the bundle. The assumption that the One thing to note though is we don't see the issues with |
I think the best bet is to do that. I think for electron the default is to skip polyfilling it (but will keep the import in place) though, not sure why it did not resolve it from the correct place ...
If you're using
Short answer: Yes. I have thought about implementing the URL parsing/formatting inline so we can have more control as I've mentioned above. When I moved from
The thing is, there's so many package that does this and we have no other way round - even
I am 50/50 on this - on one hand I want to ship the least transpiled/minified/transformed code possible, so users downstream can optimise however they wanted to (and even dig into the source code when needed), but on the other hand I do agree that there's a certain level of discrepancy between people's Webpack setups which sometimes make issues very hard to track down (mostly for "non-browser" rendering). For example, I also had an item on my road map to ship ES7+ bundles for the overlay, which would provide performance gains for Webpack 5/native ESM users. On the other hand, this is kinda against what the industry is doing - people more often than not exclude Moving on I'll alter tests so that they run with all these native polyfills disabled (that's also what Webpack 5 will ship by default). Extracting the runtime and preprocessing it can be negative for performance and since there are a lot of pieces (most of them are single files already) that have to be embedded separately I don't see how we can have a lot of gains from that. |
I'm trying to do just that right now. It's the first time I dig deep into webpack and stuff really, so my attempts so far are failing 😦. Any hints?
Thx, I didn't realize that hot middleware and dev server would have different integrations in the new version! I'll try that.
Why not use the Web API
True. The fine for now.
I agree with your points on optimization. It would be much better to have bundlers that can work reliably and give users the control, rather than taking it away. I'd be happy if it just worked really, but this integration had surprisingly many issues so far. In this sense, splitting into multiple packages could allow users to pick the package to use - pre-bundled or raw. I was also under the impression that people try to avoid transpiling the I'm cool if we make it work without the splitting, but the idea of transpiling the
I can help with preparing the test cases for |
Erm ... maybe you can use
I think what you're suggesting is that we provide multiple bundles, rather than splitting the packages. The point is, most of these files are being injected by the plugin, so you have little to no choice on which one we're going to use. They are also mostly single files already, apart from the dependencies (well, technically speaking, apart from the overlay, this plugin only have 1 runtime dependency - native-url`). Bundling would help, but for most files it would be unnecessary complexity (unless we start shipping ESM builds - that is another topic).
Again, transpiling
It would be greatly appreciated if you can create and PR an example (see other examples in this repo). I have plans to make them function as both examples and regression test cases with other integrations (we have the testing setup ready, just need to wire them up). |
Currently the runtime is not pre-processed, and this causes a lot of troubles when trying to use it with electron in a sandboxed environment.
The text was updated successfully, but these errors were encountered: