Open olange opened 3 years ago
<link rel=preload …>
techniques for now.babel.config.json
{
"plugins": [
["@babel/plugin-proposal-decorators", { "decoratorsBeforeExport": true }],
["@babel/plugin-proposal-class-properties", { "loose": true }]
]
}
snowpack.config.js
module.exports = {
…
plugins: [ '@snowpack/plugin-babel' ],
…
};
package.json
{
…
"devDependencies": {
"@babel/plugin-proposal-class-properties": "7.12.1",
"@babel/plugin-proposal-decorators": "7.12.12",
…
},
…
}
@babel/plugin-proposal-class-properties
› option loose
: when true, class properties are compiled to use an assignment expression instead of Object.defineProperty
, which is slower; for an explanation of the consequences of using either, see Definition vs. Assignment (TL;DR in Part 5)@babel/plugin-proposal-decorators
› option decoratorsBeforeExport
: an option that was added to help TC39 collect feedback from the community by allowing experimentation with both possible syntaxes: export @decorator class Bar {}
(decoratorsBeforeExport: false) vs @decorator  export class Foo {}
(decoratorsBeforeExport: true)webapp/snowpack.config.js
// Snowpack Configuration File
module.exports = {
mount: {
static: { url: "/", static: true },
// components: { url: "/components" }
},
plugins: [ '@snowpack/plugin-babel' ],
packageOptions: { },
devOptions: { output: "stream" },
buildOptions: { out: "build", sourcemap: true },
optimize: { }
};
static/
subfolder at root URL /
; handle/transform the source files of the components/
subfolder and mount them at the /components
URL; the static HTML files can reference those source files with import … from components/module.js
static/
subfolder will be placed at the root of the build/
subfolder; and the source files of the components/
subfolder will be built for production, that is, optimized/bundled/minified/treeshaken/etc., and placed in the build/_snowpack/
subfolder;build/
subfolder will be used as the source of Firebase Hosting's deployment; it is therefore linked to Firebase's configuration (firebase.json
).sourcemap: true
in buildOptions
output: "stream"
in devOptions
, as Snowpack might be run in parallel with other commands from the parent package start
scriptsdarcade.app
and d-arcade.web.app
), which only serves static assets (thru its CDN); we don't use the Firebase Functions or Firestore.webapp/build/
subfolder; and it can be used to preview the statically built webapp, from the same subfolder.firebase.json
hosting.public: "webapp/build"
setting of Firebase states the same folder as the buildOptions.out: "build"
option of Snowpack (in webapp/snowpack.config.js
hereafter)hosting.predeploy: "nom run build:webapp
ensures that we have a fresh & clean production build, before deploying to Firebase Hosting.{
"hosting": {
"public": "webapp/build",
"predeploy": "npm run build:webapp",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
}
package.json
deploy
script deploys the static assets of the webapp/build/
subfolder to Firebase Hosting (defined in firebase.json
hereabove);build:webapp
script will be run (idem);start:firebase
script can be used to preview the static production built that would be deployed with the static dev server of Firebase.start:webapp
and build:webapp
rely on Snowpack.{
…
"scripts": {
…,
"start": "run-p start:webapp",
"start:webapp": "npm --prefix webapp run start",
"start:firebase": "firebase serve --only hosting",
"build": "run-s build:*",
"build:webapp": "npm --prefix webapp run build",
"deploy": "firebase deploy --only hosting"
},
…
}
webapp/snowpack.config.js
The buildOptions.out: "build"
option of Snowpack states the same folder as the hosting.public: "webapp/build"
setting of Firebase (in firebase.json
here above):
module.exports = {
…,
buildOptions: { out: "build" … },
…
};
Snowpack has support for monorepo layout and packages linked with npm link
or NPM Workspaces:
Try to find an example and change the build pipeline to support such layout.
We'll need to review our choices, as Snowpack announced last week on their website that they would not actively maintain the project anymore:
« Update (April 20, 2022):
Snowpack is no longer actively maintained and is not recommended for new projects.
Check out Vite for a well-maintained Snowpack alternative. See also: esbuild, parcel »
I guess there is no urgency, the tooling was mature, adopted and they'll fix security issues for a little while. And on our side, we're using the Modern Web Dev stack for the ‹h3-worldmap› web component.
I was not far from using that Modern Web Dev tech stack in January 2021, when I first considered which tooling to use — but settled for Snowpack, as it was simpler to setup, with our various project parts.
Desired features
Actions
DONE
25.01 OL Parcel image transformer (Sharp)DONE
25.01 OLDONE
22.01 OLDONE
26.01 OL opiniated build of StorybookDONE
25.01 OL Snowpack 3 with esbuild and Babel plus NPM workspaces; see motivationsDONE
26.01DONE
19.01 OL hosting & serveDONE
25–26.01 OL dev & buildsee implementation details, as well as the details of its integration with Firebase
deploy
hereafterDONE
26.01 OL see implementation details hereafterTODO
TODO
secure: true
todevOptions
of SnowpackTODO
DONE
25.02 OLDONE
25.02 OLWONTFIX
25.01 OL for the caching and preloading, we'll go with simplepreload
technique and browser cache for now; we'll come back to SW for background sync and streaming updates of the game stateDONE
26.01 OL yEd diagram wiki › Toolchain page with diagramReference articles
See also
18 Add ‹hexgrid› module to webapp & monorepo layout