question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parcel 2: Vue transformer

See original GitHub issue

Create the @parcel/transformer-vue package in packages/transforms/vue. This package is a Parcel 2 transform plugin for Vue. It should be based on the VueAsset from Parcel 1.

The @parcel/transformer-vue package is responsible for the following things:

  • Parsing Vue SFCs with @vue/component-compiler-utils
  • Extracting scripts, styles, and templates as child assets
  • Compile templates
  • Compile CSS modules
  • Compile scoped styles
  • Insert HMR runtime
  • Combine the results into JS and CSS child assets

Additional features above what Parcel 1 offers to consider:

  • Support for external script and style tags (#1333)
  • Support for CSS source maps (#2721)
  • Remove minification from the transformer - it will be handled by the optimizer, and sometimes causes issues like #1183

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:12
  • Comments:25 (11 by maintainers)

github_iconTop GitHub Comments

11reactions
yyx990803commented, Apr 30, 2020

Some pointers for whoever interested in working on it:

Vue 3 SFC transform should be using https://github.com/vuejs/vue-next/tree/master/packages/compiler-sfc

The docs are non-existent yet, but the types in the source code are pretty self-explanatory. I would also recommend using https://github.com/vuejs/rollup-plugin-vue/tree/next and https://github.com/vuejs/vue-loader/tree/next as references.

The general idea is that the base transform will parse the SFC and rewrite it into JavaScript code that make additional “virtual requests” to the same *.vue file but with different query params. These requests would come back to the transform and the transform should parse the query and perform appropriate transforms for each part of the SFC.

9reactions
RobertWHurstcommented, Oct 20, 2019

It doesn’t look like much, but it may be the first vue component build with Parcel 2.

src:

<template>
  <div>
    <header>
      <h1>I'm a template!</h1>
    </header>
    <p v-if="helloWorld">{{ helloWorld }}</p>
    <p v-else>No message.</p>
  </div>
</template>

<script>
export default {
  data: () => ({
    helloWorld: 'Hello World'
  })
}
</script>

rendered: Screen Shot 2019-10-20 at 10 34 24 AM

Next I’ll be implementing HMR, external blocks, and custom blocks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

@parcel/transformer-vue - npm
Start using @parcel/transformer-vue in your project by running `npm i @parcel/transformer-vue`. There are no other projects in the npm ...
Read more >
Vue - Parcel
Parcel supports Vue automatically using the @parcel/transformer-vue plugin. When a .vue file is detected, it will be installed into your project automatically.
Read more >
@parcel/transformer-vue NPM | npm.io
Parcel is a compiler for all your code, regardless of the language or toolchain. Parcel takes all of your files and dependencies, transforms...
Read more >
parcel-transformer-vue2 - npm package - Snyk
Vue 2 transformer plugin for Parcel 2. Installation. Install this package by npm install parcel-transformer-vue2 --save-dev.
Read more >
@parcel/transformer-html | Yarn - Package Manager
Fixed · Update lmdb-js. · Update napi-rs to v2 - Details · Fix SWC targets for older browsers - Details · Add SWC...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found