Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Proposal: Use webpack-dev-server instead of watch mode #1027

Closed
@shiv19

Description

@shiv19

Current HMR in {N} 6 is taking quite a lot of time on larger projects. On the project I work on, it takes about 8 to 13 seconds for the webpack in watch mode to bundle the changes. The process of syncing to the device is quite fast. It's the bundling process that is slowing HMR down right now.

After reading up on how to optimize webpack bundling speeds I came across webpack-dev-server, and sure enough, it was blazing fast. This is because dev-server doesn't write the files to the file system. However, there is an optional parameter in the webpack config file with which you can tell it to write to the file system, even then this is way faster when compared to watch mode.

To put things into perspective, on the same project where I got bundling speed of 8 to 13 seconds with watch mode, I got 1 to 2 seconds of bundling speed with webpack dev server. And that's a really major improvement I would say.

I've demonstrated it in a project here
git clone https://github.com/shiv19/nativescript-sdk-examples-js.git
npm i
npm run dev-server

notice how fast the bundling works with dev-server.

Adding this to the webpack.config.js's config object makes it so that the dev-server writes the changes to the file system

devServer: { // https://webpack.js.org/configuration/dev-server/#devserverwritetodisk-
    writeToDisk: true
}

Without Dev server
https://drive.google.com/file/d/168E25V1J9UyimjxbOAV4KO-sm74wKB66/view?usp=sharing

With Dev server
https://drive.google.com/file/d/1Vwb799OZw5STUEOkKu_GCqT2loFu91hT/view?usp=sharing

About webpack caching,
I've tried using webpack caching, it messes up when you want to build for the other platform.
Let's say you used webpack caching to build for Android, now when you build for iOS, android version of some plugins can end up in the ios bundle (this happened to me with nativescript-bluetooth plugin).

Metadata

Metadata

Assignees

Labels

needs more infoperformanceDescribes issue related to performance problems and improvementsresearchDescribes issue that needs research if it is possible and what is the best way to implement it

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions