Giter VIP home page Giter VIP logo

Comments (17)

catamphetamine avatar catamphetamine commented on May 11, 2024

Ok, added this info to the docs.

from universal-webpack.

adailey14 avatar adailey14 commented on May 11, 2024

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.

catamphetamine avatar catamphetamine commented on May 11, 2024

it seems like server_configuration from universal_webpack still requires webpack.

What makes you think so

from universal-webpack.

adailey14 avatar adailey14 commented on May 11, 2024

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.

catamphetamine avatar catamphetamine commented on May 11, 2024

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.

adailey14 avatar adailey14 commented on May 11, 2024

Ah I understand! Thank you.

from universal-webpack.

adailey14 avatar adailey14 commented on May 11, 2024

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.

adailey14 avatar adailey14 commented on May 11, 2024

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.

catamphetamine avatar catamphetamine commented on May 11, 2024

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.

adailey14 avatar adailey14 commented on May 11, 2024

Ok thank you, that makes sense.

from universal-webpack.

catamphetamine avatar catamphetamine commented on May 11, 2024

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.

adailey14 avatar adailey14 commented on May 11, 2024

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.

catamphetamine avatar catamphetamine commented on May 11, 2024

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.

catamphetamine avatar catamphetamine commented on May 11, 2024

I can make a simple shortcut though.
Like universal-webpack/server.
Yeah, I guess I'll make it now.

from universal-webpack.

adailey14 avatar adailey14 commented on May 11, 2024

Yeah I don't know enough about structuring npm packages...

from universal-webpack.

catamphetamine avatar catamphetamine commented on May 11, 2024

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.

adailey14 avatar adailey14 commented on May 11, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.