Skip to content
This repository has been archived by the owner on Apr 21, 2022. It is now read-only.

[plugin-bundle-node] Bundling of peer/optional dependencies? #37

Open
avocadowastaken opened this issue Apr 10, 2019 · 2 comments
Open

Comments

@avocadowastaken
Copy link
Contributor

avocadowastaken commented Apr 10, 2019

While trying to bundle cli app with @pika/plugin-bundle-node I found few problems:

  1. It bundles all externals, even if they are in dependencies or peerDependencies, so these dependencies will be bundled and installed.
    Solution: Notify user if there are dependencies or peerDependencies in package.json and add them to externals.

  2. Same thing as 1., but with optional dependencies (not optionalDependencies), which not listed in package.json, but can be used with module. (e.g. pg, mysql packages that not listed in package.json of orm packages)
    Solution: Add option to pass externals. (Also can be as solution for 1.)

  3. I was using ink and react to build cli interface, and both of these libs requires to list namedExports in rollup-plugin-commonjs.
    Solution: Add option to pass namedExports for each module.

  4. As I said in 3., I was using react which has NODE_ENV checks inside, that's why bundle becomes really big.
    Solution 1: Always pass process.env.NODE_ENV=production with rollup-plugin-replace.
    Solution 2: Add option to pass env variables and replace them with rollup-plugin-replace.

  5. Does not work without @pika/plugin-build-node.
    Solution: Use dist-node/index.bundle.js only if dist-node/index.js wasn't created. Otherwise output to dist-node/index.js and do not skip bundle without --publish flag. (We also will need incremental builds for this, related to https://github.com/pikapkg/pack/issues/29)

From minor problems I found that there are no way to pass minNodeVersion and rollup-plugin-node-resolve warns about deprecated module option. I'll create PRs for them, but really want to discuss listed issues.


Update:


Update 2:

  • Section 5.
@FredKSchott
Copy link
Owner

Hey @umidbekkarimov, thanks for taking such a deep look into this, it's really appreciated.

I just went through your PRs, but don't have time now to respond to these remaining, larger issues in full now. Let me think through them a bit tomorrow and then respond then.

@avocadowastaken
Copy link
Contributor Author

Hello @FredKSchott! No problems at all, it took me about a week to came up with this proposals. And I'm using local config, so no blockers from you.

@FredKSchott FredKSchott changed the title plugin-bundle-node enhancement [plugin-bundle-node] Bundling of peer/optional dependencies? Jan 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants