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

(fix): added rollup plugin @zerollup/ts-transform-paths, injected as … #374

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"@types/shelljs": "^0.8.5",
"@typescript-eslint/eslint-plugin": "^2.12.0",
"@typescript-eslint/parser": "^2.12.0",
"@zerollup/ts-transform-paths": "^1.7.8",
"ansi-escapes": "^4.2.1",
"asyncro": "^3.0.0",
"babel-eslint": "^10.0.3",
Expand Down
5 changes: 5 additions & 0 deletions src/createRollupConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import replace from '@rollup/plugin-replace';
import resolve from 'rollup-plugin-node-resolve';
import sourceMaps from 'rollup-plugin-sourcemaps';
import typescript from 'rollup-plugin-typescript2';
import transformPaths from '@zerollup/ts-transform-paths';
import { extractErrors } from './errors/extractErrors';
import { babelPluginTsdx } from './babelPluginTsdx';
import { TsdxOptions } from './types';
Expand Down Expand Up @@ -50,6 +51,9 @@ export async function createRollupConfig(opts: TsdxOptions) {
tsconfigJSON = fs.readJSONSync(resolveApp('tsconfig.json'));
} catch (e) {}

const pathTransformer = (service: any): any =>
transformPaths(service.getProgram());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these be more specific than any? transformPaths is written in TS, so I think it can be.

Also do you know if the second arg isn't necessary? It has an exclude option, not sure if we should pass tsconfigJSON.exclude into there or if it's read automatically (and the exclude option is just an override maybe?? idk the docs aren't comprehensive)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, yea) transformPaths has types LanguageService and CustomTransformer - need to use,
to be fixed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


return {
// Tell Rollup the entry point to the package
input: opts.input,
Expand Down Expand Up @@ -153,6 +157,7 @@ export async function createRollupConfig(opts: TsdxOptions) {
target: 'esnext',
},
},
transformers: [pathTransformer],
}),
babelPluginTsdx({
exclude: 'node_modules/**',
Expand Down
14 changes: 14 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,20 @@
semver "^6.3.0"
tsutils "^3.17.1"

"@zerollup/ts-helpers@^1.7.4":
version "1.7.4"
resolved "https://registry.yarnpkg.com/@zerollup/ts-helpers/-/ts-helpers-1.7.4.tgz#59ac8c643b8cc6def5449691630091226991da36"
integrity sha512-8JLREeiO6MtmJhU8kw/eNwi+HKlh/K3cMlpH6HVbW53bqhAgTvt8KnIqFh9FMNbCL3QDht35g8VJHVWYkMEt2A==
dependencies:
resolve "^1.12.0"

"@zerollup/ts-transform-paths@^1.7.8":
version "1.7.8"
resolved "https://registry.yarnpkg.com/@zerollup/ts-transform-paths/-/ts-transform-paths-1.7.8.tgz#e9de4ed23e9b6f584b9a625141326456f71d0a8a"
integrity sha512-xh6KZRF3cD/pYeQypADTh7U9zAU8vgG7PvUT9m20mW8rsiUF69OKDM+9CsR483ceXVh5PC5AHUA/GAvsJ1iVbw==
dependencies:
"@zerollup/ts-helpers" "^1.7.4"

abab@^2.0.0:
version "2.0.2"
resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.2.tgz#a2fba1b122c69a85caa02d10f9270c7219709a9d"
Expand Down