-
-
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
Option to disable bundling for building libraries #7254
Comments
Thanks for opening this. I think we should support this. It will require a different bundling strategy (i.e. 1:1). Luckily it should be possible in Parcel's architecture since bundlers are plugins. We're currently reworking the API a bit, but no reason it won't be possible soon. |
I'd love have this feature! For context, I'm working on an app where most of the frontend codebase is in untranspiled JS files that declare variables and functions in the global scope. The short-term goal is to run each file through Parcel for transpilation and minification, but not bundling, because we need to keep code in the global scope (not inside IIFEs) for now. The longer term strategy is to migrate to modules, using Parcel to properly bundle everything and support TypeScript, but the need for just transpilation and minification is more immediate. |
This should be the default for libraries if However, I note that Parcel automatically excludes |
The default for building libraries in Parcel does not include dependencies from node_modules, only your own code. |
Yeah, I updated the comment after reading the docs again. (Forgot to save the edit earlier 😂) |
Still bundle together even
"main": "dist/cjs/index.js",
"module": "dist/esm/index.mjs",
"targets": {
"default": {
"outputFormat": "commonjs",
"isLibrary": true
},
"main": {
"includeNodeModules": false,
"distDir": "dist/cjs",
"outputFormat": "commonjs"
},
"module": {
"includeNodeModules": false,
"distDir": "dist/esm",
"outputFormat": "esmodule"
}
}, |
@devongovett I tried the new bundler-library plugin, and a few things so far are unintuitive.
For reference of another project, https://github.com/unjs/unbuild takes this approach of basically emitting every file to the dist with multiple variants based on your exports. I could be convinced that maybe I shouldn't want this, but currently what I want is |
Discussed in #6845
Originally posted by Thoud August 31, 2021
Hey everyone,
currently I'm trying to create a React component library which gets published to a registry and imported by another project.
My goal is to have a library which builds the source code in the same file structure as in src.
The idea behind this is that the project which imports the library has the possibility to only import a single component out of there instead of importing the whole thing. In addition to that it would be nice if the components (when importing each other) would not get bundled up into huge files with all their imported files but instead being build into individual files and only being referenced (just like node_modules but on a component level). Here a short example of what I mean:
Component B imports Component A and C.
All three files get compiled to individual files but instead of dumping the code from Component A and C into B and then compile Component B into a big file , it would be great if they would get compiled separately but in a way that component B references the other two, so that no code duplication occurs.
I hope that my explanation makes any sense, if not please let me know which parts are unclear and I will give my best to clarify them.
I'm happy for any help or hints to the solution :D
🙋 feature request
Add an option to disable bundling, only transpile. While I'm aware that this feature is very big, I still wanted to request it to hear your thoughts.
🤔 Expected Behavior
When building a library I expect running
npx parcel build [input]
only to compile source, not bundle it.😯 Current Behavior
Parcel always bundles (with the exception of being able to exclude node modules).
💁 Possible Solution
Parcel could add a new option (e.g.
--no-bundle
) that could also be the enabled viapackage.json
somehow, possibly as the default for libraries. This feature would also normalize glob inputs, so maybe Parcel could also start recognizing glob values for thesource
field:but I haven't thought it through.
🔦 Context
When building a library, bundling is unwanted, I want to compile the source files in the same structure as they are in the source directory.
The text was updated successfully, but these errors were encountered: