Docsify: Migrate to `webpack`

Created on 11 May 2020  路  5Comments  路  Source: docsifyjs/docsify

Status PoC

We are currently using rollup for bundling. Though we never faced a major issue with it, rollup is built for libraries which are node focuses not the browser. We will be using rollup for our CLI project but as docsify is browser library, I would prefer to migrate to webpack like its always recommended to use webpack for browser code.

PoC welcome needs discussion

Most helpful comment

The general advise for people asking "rollup or webpack?" has been use to use rollup for distributable packages (browser and/or node) and webpack for applications. This advise was given early on mostly due to webpack v2's inability to output ES6 modules, but it largely holds true today as rollup is typically faster and produces smaller bundle sizes while webpack tends to be more flexible for app-specific use cases like code splitting. Given this advise and without any other information or preferences to consider, Rollup would typically be the first choice for a distributed bundle like docsify's.

My preference would be to 1) lower the priority of this task in favor of user-facing issues and 2) commit only to exploring webpack as an option if/when time allows or the need presents itself. Once we have separate webpack and rollup builds available we can compare build time, bundle size, learning curve, features, concerns, etc.

All 5 comments

The general advise for people asking "rollup or webpack?" has been use to use rollup for distributable packages (browser and/or node) and webpack for applications. This advise was given early on mostly due to webpack v2's inability to output ES6 modules, but it largely holds true today as rollup is typically faster and produces smaller bundle sizes while webpack tends to be more flexible for app-specific use cases like code splitting. Given this advise and without any other information or preferences to consider, Rollup would typically be the first choice for a distributed bundle like docsify's.

My preference would be to 1) lower the priority of this task in favor of user-facing issues and 2) commit only to exploring webpack as an option if/when time allows or the need presents itself. Once we have separate webpack and rollup builds available we can compare build time, bundle size, learning curve, features, concerns, etc.

The general advise for people asking "rollup or webpack?" has been use to use rollup for distributable packages (browser and/or node) and webpack for applications

Actually I feel the same for most cases. Rollup is probably better for the docsify bundle.

In some cases though, Webpack's ES-spec-compliant features come in handy when you can not do certain things with Rollup. As an example, one time I wanted to make "package protected" exports, so that if anyone outside of my package tried to import something it would thrown a runtime error. I'm not sure about now, but the last time I tried to achieve this with Rollup (with circular dependencies in the mix) I couldn't get the module hoisting to work as expected, but it worked with Webpack.

I think in general starting with Rollup first for a lib and only moving to Webpack if needed is the way to go. :+1:

1) lower the priority of this task in favor of user-facing issues

:+1:

if/when ... the need presents itself

:+1:

With all that said, what about Webpack (Parcel) for docsify sites generated by the CLI? :thinking: Personally I really like the idea of keeping it simple with script tags (traditional or of type=module).

Removed it from the 5.0 Todo.

Agreed, though I would favor webpack personally cause I always get lost with the rollup's dependencies resolving thing. eg https://github.com/docsifyjs/docsify/issues/1058, https://github.com/docsifyjs/docsify/issues/1057

(Pretty sure I did miss there something)

So, anyway, if someone takes this would be great, though not a priority or blocker. 馃憤

I don't think we _need_ to switch to Rollup. We learnt about the caveat (it treats missing dependencies as warnings), so now we know. And now we also have a tests in place to catch missing dependencies once I get a second review so I can merge #1189.

Also, we can add this config to Rollup to throw an error instead of a warning: https://github.com/rollup/rollup/issues/1906#issuecomment-561055996

I think we should close this, as we don't have a _need_ to convert to Webpack. Let's re-open this if/when someone needs to convert to Webpack for some reason.

Let's focus on features/improvements.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SidVal picture SidVal  路  3Comments

sijakret picture sijakret  路  3Comments

soulfly picture soulfly  路  4Comments

nothingrandom picture nothingrandom  路  5Comments

smlbiobot picture smlbiobot  路  5Comments