Comments (17)
Ok, added this info to the docs.
from universal-webpack.
Hi guys, I'm trying to understand this, because I also want to remove webpack from my production dependencies.
What I don't understand, is it seems like server_configuration from universal_webpack still requires webpack. So even by stubbing the configuration passed into server_configuration, you haven't eliminated the production dependency on webpack. Is that right? Or can you help me understand that? Thank you in advance.
from universal-webpack.
it seems like server_configuration from universal_webpack still requires webpack.
What makes you think so
from universal-webpack.
I thought so from looking at the source file:
universal-webpack/source/server configuration.js
At line 3 it imports webpack:
import webpack from 'webpack'
Am I looking in the wrong place?
from universal-webpack.
Yes, it uses webpack
for its plugins: it removes webpack.HotModuleReplacementPlugin
and webpack.optimize.CommonsChunkPlugin
and also adds webpack.optimize.LimitChunkCountPlugin
.
The original poster said:
since i deploy the built bundle already.
Therefore, currently webpack
is used during build but it's not used when running the built bundle
from universal-webpack.
Ah I understand! Thank you.
from universal-webpack.
Ok I understand what was throwing me off now. server_configuration() does require a relatively full webpack configuration. It's server() that only requires context and output: {path: }. This is what you updated in the documentation - I think in @papigers initial post he shows an example using server_configuration() but really he meant server().
from universal-webpack.
Hi sorry to keep harping on this, I appreciate any help.
I find that I am still hitting a dependency on webpack. Running this line in production is trying to find webpack:
import { server } from 'universal-webpack';
If I go into index.common.js in node_modules/universal-webpack and comment out these lines:
server_configuration : require('./build/server configuration').default,
client_configuration : require('./build/client configuration').default,
serverConfiguration : require('./build/server configuration').default,
clientConfiguration : require('./build/client configuration').default,
Then I can get it to work. So it seems that just by importing universal-webpack I am hitting the dependency on webpack. So I can also get around this by requiring server like this:
import server from 'universal-webpack/build/server';
instead of like this:
import { server } from 'universal-webpack';
Does this make sense?
from universal-webpack.
Yes, it does: seems that indeed webpack
is required for running the .common.js
bundle.
Presumably this is fixed in Webpack 2
because it should "tree shake" the unused dependencies.
But for Webpack 1
, as a workaround, import server from 'universal-webpack/build/server'
is gonna work without any difference.
from universal-webpack.
Ok thank you, that makes sense.
from universal-webpack.
Oh, disregard my comment above: here Node.js is used, not Webpack. And Node.js doesn't "tree shake". So, yes, the workaround you proposed seems to be the one:
import server from 'universal-webpack/build/server'
from universal-webpack.
Great, seems like it works. I wonder what is the right way to represent universal-webpack's dependency on webpack. I guess it might make sense to break up the build_configuration aspect from the runtime aspect. Then the build_configuration part would depend on webpack and the runtime part would not. Not sure that is worth doing just interesting to think about.
from universal-webpack.
And how would you require it then?
You only have one index.js
and one way or another it's gonna be a separate require()
from lib
.
from universal-webpack.
I can make a simple shortcut though.
Like universal-webpack/server
.
Yeah, I guess I'll make it now.
from universal-webpack.
Yeah I don't know enough about structuring npm packages...
from universal-webpack.
I added two new exports:
import { client, server } from 'universal-webpack/config'
import startServer from 'universal-webpack/server'
You can test these in the newly released version.
from universal-webpack.
Very cool, I won't be able to test for a while. I'm still on Webpack 1 so not ready for the latest version of universal-webpack. Hoping to have some time to make the upgrade soon.
from universal-webpack.
Related Issues (20)
- webpack-dev-server does not support es6 modules HOT 2
- support css-loader v2 HOT 7
- Error: [universal-webpack] Your server source file must export a function. Got [ 'libserver' ] HOT 7
- typescript signatures for clientConfiguration/serverConfiguration do not include options HOT 2
- Advanced config HOT 5
- webpack-chunks.json not found HOT 1
- How to config webpack-chunks.json path? HOT 3
- Compatibility with css-loader@3 broken HOT 2
- parser: { requireEnsure: false } } HOT 1
- support css loader v3 HOT 1
- [Question] SSR Support for Files like png and svg HOT 3
- webpack-isomorphic-tools to universal-webpack
- [Question] ssr bundle does not have styles
- DeprecationWarning HOT 2
- Flash of Unstyled Content with Webpack 4 HOT 2
- Nodemon causes Error 503 on Hot reload HOT 8
- Using dynamic imports causes the output filename to be the first encounted chunk name when generating server bundle HOT 4
- Fails to run server using DllPlugin, "ReferenceError: vendor is not defined"
- webpack-serve has been DEPRECATED HOT 2
- Readme is difficult to follow HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from universal-webpack.