-
-
Notifications
You must be signed in to change notification settings - Fork 747
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
Request: Add purify.min.js and purify.js to package.json exports #1050
Comments
Why do you need to require/import the minified file? Webpack should take care of minifying the cjs or esm files that are normally required/imported based on the package exports. |
Correct, webpack by itself will do the minifying, however, in dev mode, I do not want them modified. And to accomplish that, a conditional is needed within the alias to determine when the app is in dev or production mode. While other stuff in dev mode stays minified. The webpack optimization module is global and can't be defined on a per package basis other than using an alias. There are other packages that are significantly larger when unpacked in dev mode that don't need to be unpacked, and dramatically increase sizes. |
Hey all, I am not sure what to do here, any advice? :D |
In a perfect world, these two files could be added to the package, and I'd forever hold a man crush for you. But your project, up to you. |
What would break if we did that? If the risk for breakage is low, we can look at a PR of yours, maybe? |
Shouldn't have any conflicts at all since I have not modified your default.s I've been using a modified copy since I put my issue in. Only the modules listed in your package exports will be allowed to be utilized by outside packages, and any others will just get And with my code above, I just added two additional exports. I forget, but you guys made this change over from main to exports a few versions ago, which is when it stopped working, pretty much just need to re-define them in the new exports. And yeah, if you want me to do a PR I can, I figured since it's a few lines of code, whoever wants to. But I can if you need. Edit: Added a pr. Appreciate it. |
Cool, thanks 😄 |
Adds two new entries to the package.json
export
entrypoints list.Background & Context
At present, using DOMpurify in combination with webpack 5. To control the dev and production environment, being able to use an alias, and to decide when to minify and when to not, I would need access to each of the two files individually.
Feature
In the
package.json
file, change the code:From:
To:
After adding the changes locally, webpack works great and grabs each file depending on the environment.
Without this change, webpack does not build, and throws a failure error:
According to the documentation, webpack has a way to ignore the export fields by defining
exportsFields: []
, but it is global only. It cannot be controlled based on each alias. You either get all or nothing. And that would kill many other packages using exports.Without this change, the project would either be stuck at v3.1.7, or removal of the alias from webpack all-together.
The text was updated successfully, but these errors were encountered: