Skip to content
This repository has been archived by the owner on Dec 30, 2021. It is now read-only.

Run generated code from plugins through build scripts #104

Open
dlindenkreuz opened this issue Jun 1, 2020 · 0 comments
Open

Run generated code from plugins through build scripts #104

dlindenkreuz opened this issue Jun 1, 2020 · 0 comments

Comments

@dlindenkreuz
Copy link
Contributor

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"
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant