Skip to content

Request: Extract chunks as entry #35

@lukeed

Description

@lukeed

One of the things I like about Webpack is that I had the able to define an entry as an array of files. Typically these are names of dependencies & not direct file paths.

Then, when importing bits from this array-entry, the useful pieces (after code shaking) are placed in that new, generated file.

This is particularly (and commonly) useful for when there's a single app entry & a declaration of shared vendor scripts. In such case, Splittable AFAIK won't generated a shared _base.js.

module.exports = {
  entry: {
    app: './src/app.js',
    vendor: [
      'vue',
      'vue-router', 
      'firebase/database',
      '...'
    ]
}
// app.js (simple)
import Vue from 'vue'
import Router from 'vue-router'
import 'firebase/database'

Final output should contain all the application script in app.js and all useful chunks within vendor.js.


This could probably be achieved already, but it seems pretty silly & I think there'd be some unnecessary code to string together the vendor file to _base:

// app.js
import Vue from 'vue'
import Router from 'vue-router'
import 'firebase/database'
import { item } from 'fake-dep'

// now do custom stuff
// vendor.js
// just redeclare all application imports

import Vue from 'vue'
import Router from 'vue-router'
import 'firebase/database'
import { item } from 'fake-dep'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions