Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ts-transform-paths with rollup-plugin-typescript2 #11

Closed
iliyaZelenko opened this issue Apr 7, 2019 · 5 comments
Closed

ts-transform-paths with rollup-plugin-typescript2 #11

iliyaZelenko opened this issue Apr 7, 2019 · 5 comments

Comments

@iliyaZelenko
Copy link

iliyaZelenko commented Apr 7, 2019

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:

image

Can you suggest something? Perhaps there are other packages for this?

@zerkalica
Copy link
Owner

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

@iliyaZelenko
Copy link
Author

@zerkalica my project: https://github.com/iliyaZelenko/tiptap-vuetify

I can try with ttypescript but preferably without this and the option that I use.

@zerkalica
Copy link
Owner

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/**/*",

@iliyaZelenko
Copy link
Author

@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.

@iliyaZelenko
Copy link
Author

Everything is working! Thanks, it really helped me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants