-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Ability to ignore modules at least in well-known environments #474
Comments
I've created a repo to reproduce the problem: https://github.com/gimenete/electron-parcel-bug-report |
any news on this ? unable to use parcel in electron environments :( |
I toyed around with this by skipping in dependencies.js anything that looked like packages. I'm guessing Parcel's previous require stuff would get stuff loaded, but I'm still studying how things get added to bundles. I'm going to keep throwing myself at it for a bit. |
I'm using it in an Electron app, can anyone guide me either how to fix this in a PR or suggest a workaround? I'd happily do a PR. |
OK, it seems a workaround can be something like this, so Parcel won't bundle it. <html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script>
window.nodeRequire = require;
delete window.require;
delete window.exports;
delete window.module;
const electron = nodeRequire('electron');
</script>
</head>
<body>
<div id="root"></div>
<script src="./index.js"></script>
</body>
</html> Or another solution is, if you need it in the renderer js entry file (which is bundled with Parcel), you can require it like this: // renderer.js
const electron = eval(`require('electron')`) /* or nodeRequire if you changed it */ By using |
Per the guidance of @devongovett in #448, I added a simple and dumb check to Resolver.js to return null if the filename started with However, because I don't know if I have exhausted all of the options, but I think parcel would need to disallow plugins from altering built-in packagers for this feature to be stable. |
@maccelerated I think the solution above I posted is simpler, no? |
I was trying to prevent Parcel from bundling any package, but yeah, escaping electron like that would get you up and running. |
escaping electron like that should be only a quick workaround. But doesn't work in all scenarios. For example if you are transpiling from typescript, you don't have much control over how typescript generates the |
@maccelerated and others: modified PR #652 for electron support. Please check if it's ok for your usecase. |
This is a 🙋 feature request.
I was trying to use parcel.js for an electron application. The goal is to have a lightweight HMR solution without the need to set up something complex. Besides I love the fine grained control you can get with
module.hot.dispose
andmodule.hot.accept
.🤔 Expected Behavior
parcel.js should not bundle the
electron
package.😯 Current Behavior
Basically parcel is trying to bundle the
electron
package itself. Internally electron does things with the file system. I cannot control that, but even more: there's no need to bundleelectron
itself with the code.💁 Possible Solution
I like the idea of having well-known environment configurations, such as eslint does. So we could have:
This would apply some additional rules to parcel due to the selected environment. For example ignoring
electron
or even ignoring allnode_modules
.💻 Code Sample
As soon as you import electron itself:
The build fails. The additional
<script>
with thosedelete
s is due to this: #321 Which is another thing the--env
idea could fix.🌍 Your Environment
The text was updated successfully, but these errors were encountered: