This is my suggestion to solve some problems we have right now with modes:
- No mode is
"default"
instead of"html"
. - “No mode” entry points don’t live in any folder, they live in the root.
- Modes live in the folder of the same name. They fallback to default. This fixes the problem of creating new modes using packages that don’t support them directly.
- We get rid of the
src
folder. - We move type from
index.ts
totype.ts
. -
client
andserver
entrypoints can be joined in anindex
if not present. The future entrypoints (koa, inline, build, sw…) will be independent of this. - We solve the problem of unnecessary chunks in service workers by creating service workers while running webpack only with one entry-point.
Some examples.
/index.js # Both client and server for any mode.
/package.json
/client.js # Client for any mode.
/server.js # Server for any mode.
/package.json
/amp/index.js # Client and server for amp mode.
/index.js # Client and server for any mode other than amp.
/package.json
/amp/server.js # Server for amp mode.
/index.js # Client and server for any mode and client for amp mode.
/package.json
/mymode/index.js # Client and server for mymode mode.
/index.js # Client and server for any mode other than mymode.
/package.json
/amp/sw.js # Service worker for amp mode.
/index.js # Client and server for any mode.
/sw.js # Service worker for any mode other than amp.
/package.json
/index.ts # Both client and server for any mode.
/type.ts # Type of the package, to be imported by other packages.
/package.json
@development-team opinions?