200.9MB node_modules/ directory of 1,300+ different dependencies to see a
“Hello World!” app.
95,2 MB node_modules/ directory of 500+ different dependencies to see a
“Hello World!” app.
+ imagine lots of lines of code added by Webpack in build time.
340 MB node_modules/ directory of 7000+ different dependencies to see a
“Hello World!” app.
Within package.json,
"exports": { "import": "./path/to/entry.js" }
or
"exports": { ".": { "import": "…" } }
add the following:
and
"type": "module"
"module": "./path/to/entry.js"
{
"module": "./esm/index.js",
"exports": {
".": "./esm/index.js"
}
}
{
"main": "./index-cjs.js",
"module": "./index-esm.js",
"exports": {
"require": "./index-cjs.js",
"import": "./index-esm.js"
}
}
web-only:
<script type="module" src="module.js"></script>
<script nomodule src="fallback.js"></script>
<script type="module">
import { tag } from './html.js'
const h1 = tag('h1', '👋 Hello Modules!')
document.body.appendChild(h1)
</script>
// html.js
export function tag (tag, text) {
const el = document.createElement(tag)
el.textContent = text
return el
}
// app.js
import { tag } from './html.js'
const h1 = tag('h1', '👋 Hello Modules!')
document.body.appendChild(h1)
<script type="module" src="app.js"></script>
import confetti from 'https://cdn.skypack.dev/canvas-confetti';
confetti();
Global edge cache HTTP/3 support Upconverts old Node packages to modern ES Modules JS minification Brotli / gzip compression Polyfills JS for legacy browsers and more ...
a lightning-fast frontend build tool,
designed for the modern web
node_modules/react/**/* -> http://localhost:3000/web_modules/react.js
node_modules/react-dom/**/* -> http://localhost:3000/web_modules/react-dom.js
<body>
<script type="module">
import React from 'react';
console.log(React);
</script>
</body>
single-file builds
This runs directly in the browser with
`snowpack dev`
a meta framework for shipping less JS to the client
Build-time / runtime code in one file
Supports partial hydration
---
// This JavaScript code runs at build-time.
console.log('This runs at build-time');
// Tip: TypeScript is also supported out-of-the-box!
const thisWorks: number = 42;
---
<div class="example-1">
<h1>Hello world!</h1>
</div>
---
// Example: hydrating a React component in the browser.
import MyReactComponent from '../components/MyReactComponent.jsx';
---
<!-- "client:visible" means the component won't load any client-side
JavaScript until it becomes visible in the user's browser. -->
<MyReactComponent client:visible />
Supporting:
- Typescript
- JSX
- JSON
- CSS Modules
- npm packages
uses Snowpack under the hood
- React/Preact (JSX), Svelte, Vue, and web components. (Solid & lit)
- WASM
- Node built-ins