Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

Add setup example for lang="ts" #323

Closed
mesqueeb opened this issue Jan 20, 2020 · 3 comments
Closed

Add setup example for lang="ts" #323

mesqueeb opened this issue Jan 20, 2020 · 3 comments

Comments

@mesqueeb
Copy link

What problem does this feature solve?

Currently it has a setup example for Vue files with JavaScript script tags.

I think it would be greatly beneficial for a lot of devs to add a setup example for dev who use Vue files with:

<script lang="ts">

for TypeScript (but without the class syntax)

What does the proposed API look like?

Setup example for TypeScript

import commonjs from 'rollup-plugin-commonjs' 
import VuePlugin from 'rollup-plugin-vue'
// ~~~~ typescript required plugins

export default {
  entry: 'main.js',
  plugins: [
    commonjs(),
    VuePlugin(/* VuePluginOptions */)
    // ~~~~ typescript required setup
  ]
}
@mesqueeb
Copy link
Author

compiling a vue SFC with lang="ts" worked for me with this setup:

import VuePlugin from 'rollup-plugin-vue'
import typescript from 'rollup-plugin-typescript2'

export default {
  plugins: [
    typescript({
      typescript: require('typescript'),
      objectHashIgnoreUnknownHack: true,
    }),
    VuePlugin(/* VuePluginOptions */),
  ],
  input: 'src/components/HelloWorld.vue',
  output: [
    { file: 'dist/HelloWorld.cjs.js', format: 'cjs' },
    { file: 'dist/HelloWorld.esm.js', format: 'esm' },
  ],
}

without that objectHashIgnoreUnknownHack it doesn't.

I'm not sure if this is the best way to create a module out of a Vue SFC with lang="ts".

If anyone has any advice, please let me know.

@znck
Copy link
Member

znck commented Jan 27, 2020

The requirement for objectHashIgnoreUnknownHack is fixed in #324.

@znck
Copy link
Member

znck commented Jan 27, 2020

@mesqueeb Your usage example seems correct.

@znck znck closed this as completed Jan 27, 2020
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

2 participants