FullstackAcademy / boilermaker

Code scaffold for projects
https://www.youtube.com/watch?v=7bLSuTHH4Ag&list=PLx0iOsdUOUmn7D5XL4mRUftn8hvAJGs8H
MIT License
215 stars 706 forks source link

[WIP] support async imports in npm modules #203

Open collin opened 4 years ago

collin commented 4 years ago

Some dependencies make use of async imports: import('module-name').then((defaultExport) => {})

Students who run into this issue are hit particularly hard, as it's not obvious why installing a module would cause this bug. Also it involves path construction issues which are particularly difficult to master.

This results in chunked bundles 0.bundle.js.

As configured, webpack will assume these should be fetched as GET /public/0.bundle.js

But the URL should be GET /0.bundle.js.

Deployed here: https://nameless-fjord-30998.herokuapp.com/

Used this async import:

// establishes socket connection
import('./socket').then(socket => {
  console.log('Got socket!', socket)
})

npm run deploy shows multipart bundle being added:

[deploy 29f0e89] Deploying
 8 files changed, 13998 insertions(+)
 create mode 100644 public/0.bundle.js
 create mode 100644 public/0.bundle.js.map
 create mode 100644 public/1.bundle.js
 create mode 100644 public/1.bundle.js.map
 create mode 100644 public/2.bundle.js
 create mode 100644 public/2.bundle.js.map
 create mode 100644 public/bundle.js
 create mode 100644 public/bundle.js.map