create-snowpack-app
create-snowpack-app copied to clipboard
Run generated code from plugins through build scripts
Currently, code that is generated by plugins such as @snowpack/plugin-vue is not transpiled using the respective build script.
In the following example, I'd expect esbuild to handle the nullish-coalescing operator (??
) in both src/Foo.vue
and src/Bar.js
.
CSS files that were generated during build should probably be transformed using an analogous technique.
snowpack.config.json
{
"extends": "@snowpack/app-scripts-vue",
"scripts": {
"build:js,jsx,ts,tsx": "esbuild --target=es2018"
}
}
src/Foo.vue
<template>
<div>{{ foo ?? "123" }}</div>
</template>
<script>
function bar(x) {
return x ?? "bar"
}
export default {
data() {
return { foo: null }
}
}
</script>
src/Bar.js
export function bar(x) {
return x ?? "bar"
}
Snowpack output (Foo.vue → Foo.js, does not work as expected)
function bar(x) {
return x ?? "bar"
}
const defaultExport = {
data() {
return { foo: null }
}
}
import { toDisplayString as _toDisplayString, createVNode as _createVNode, openBlock as _openBlock, createBlock as _createBlock } from "/web_modules/vue.js"
export function render(_ctx, _cache) {
return (_openBlock(), _createBlock("div", null, _toDisplayString(_ctx.foo ?? "123"), 1))
}
defaultExport.render = render
export default defaultExport
Snowpack output (Bar.js, works as expected)
export function bar(x) {
return x ?? "bar"
}