ts-transform-paths with rollup-plugin-typescript2
iliyaZelenko opened this issue · 5 comments
Hi, i tried this lib because my .d.ts
files files generated with paths that have aliases:
import Component from '~/path1/path2';
import { Component2 } from '~/path2';
I stumbled upon your package.
I tried to use this package like with rollup:
import transformPaths from '@zerollup/ts-transform-paths'
and in my rollup plugin property:
typescript({
clean: true,
transformers: [service => ({
before: [
transformPaths(service.getProgram())
],
after: []
})]
}),
I wanted to do as in the code in this example. (pre-header example)
But I get an incomprehensible error:
Can you suggest something? Perhaps there are other packages for this?
Can you provide full example with tsconfig and etc?
I use https://github.com/cevek/ttypescript#rollup to inject plugin and include it into config in my demo
@zerkalica my project: https://github.com/iliyaZelenko/tiptap-vuetify
I can try with ttypescript
but preferably without this and the option that I use.
I check your project with ttypescript, it works fine, just use.
Sorry, i have no time to dig into buggy rollup plugin (probably problem in it) or your rollup config.
g diff -- rollup.config.js
diff --git a/rollup.config.js b/rollup.config.js
index 632c460..f9965bd 100644
--- a/rollup.config.js
+++ b/rollup.config.js
@@ -5,6 +5,7 @@ import alias from 'rollup-plugin-alias'
import postcss from 'rollup-plugin-postcss'
import resolve from 'rollup-plugin-node-resolve'
import { join } from 'path'
+import ttypescript from 'ttypescript'
const isProduction = process.env.BUILD === 'production'
const srtDir = join(__dirname, 'src')
@@ -107,7 +108,8 @@ async function getConfig ({
typescript({
// это фиксит Unknown object type "asyncfunction"
// https://github.com/ezolenko/rollup-plugin-typescript2/issues/105
- clean: true
+ clean: true,
+ typescript: ttypescript,
}),
vue({
defaultLang: { script: 'ts' },
g diff -- tsconfig.json
diff --git a/tsconfig.json b/tsconfig.json
index d51f1f3..a2722ea 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -70,7 +70,10 @@
/* Experimental Options */
"experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
- "emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */
+ "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
+ "plugins": [
+ { "transform": "@zerollup/ts-transform-paths" }
+ ]
},
"include": [
"types/**/*",
@zerkalica thanks for testing this package with ttypescript
, I will use it.
Thank you for your package. I will report it works for me or not.
Everything is working! Thanks, it really helped me.