webpack / webpack/webpack

Webpack without bundling for server-side compilation

Open
#5,866 32 comments 90 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
65.9k
Forks
9.5k
Avg merge
10h 40m
Merged PRs (30d)
296

Description

Do you want to request a feature or report a bug?
Feature

What is the current behavior?
Webpack always bundles files and this is not a desirable behaviour when compiling server-side code. I know that it sounds like an oxymoron to ask for it not to bundle since webpack is a "bundler".

What is the expected behavior?
It would be great if webpack could accept an option to only compile files and then output them back out while preserving the directory structure, essentially skipping the bundling step.

If this is a feature request, what is motivation or use case for changing the behavior?
When writing a universal react application, the entire react app is shared between client and server. Moreover, may other files such as schemas, validation logic, utils, api clients, etc are also shared and need to be compiled separately for the browser and node.js. Currently, I have two webpack config files, one for client and one for server. This generates two bundled files.

While this setup works fine for now, it does negatively impact my development speed. Node.js code is really not meant to be bundled. For instance, after bundling, you can't use fs.read with a relative path anymore. The biggest issue, however, which has led me on a path to find an alternative is the terrible debugging experience. With recent versions of Node, we can use Chrome Dev Tools to debug our server application. Unfortunately, due to limitations of the dev tools, we don't have acccess to source maps when debugging the server code. Believe it or not, this is a huge nightmare when trying to debug server code and all you have is one massive webpack-generated file. There's an open issue about this problem on node.js' github repo but so far, there doesn't seem to be any fix.

I can use something like gulp-babel to compile my server code but that won't handle assets like webpack does so it won't work for react ssr. Moreover, gulp doesn't "crawl" the import statements like webpack does so I have to completely separate my server and client code into separate folders (or use a silly naming convention like ".server.js") which again causes many issues when it comes to shared files. Probably more than 50% of my application is shared files so you can imagine what a nightmare that would be trying to separate client and server.

If webpack had an option to disable the bundling step and just output files after compilation, then this problem would be resolved.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named. Start by reviewing the issue's separate client and server webpack configurations and the requested server-side compilation behavior. Done means webpack can compile server code without bundling, preserve its directory structure, and continue handling shared assets.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.