Resolve TypeScript config paths in runtime.
This repository is a monorepo containing the following packages:
Resolving tsconfig paths in node runtime
License: MIT License
Resolve TypeScript config paths in runtime.
This repository is a monorepo containing the following packages:
Currently the rollup-plugin-tsconfig-paths
declares:
typescript-paths/packages/rollup-plugin-tsconfig-paths/package.json
Lines 35 to 37 in 2a353f2
Would it be possible to add Rollup 4 support, please?
not working
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@abc/buld": [ "./packages/build/src/index.ts" ]
}
}
}
working if i remove the extension file
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@abc/buld": [ "./packages/build/src/index" ]
}
}
}
Now that Rollup v3.0.0 has been released, it would be great if this could be supported.
(I don't think anything needs to be changed except package.json
.)
There seems a problem with resolving the paths that are at the same level
Address.ts
and Company.ts
are both in the same dir src/models
The other imports are resolved nicely (thanks btw! ๐ )
# Company.ts
import { Address } from "@/models/Address";
Output:
$ yarn exec rollup -c --bundleConfigAsCjs
src/index.ts โ dist/cjs/index.js...
created dist/cjs/index.js in 409ms
src/index.ts โ dist/esm/index.js...
created dist/esm/index.js in 229ms
src/index.ts โ dist/types.d.ts...
(!) Unresolved dependencies
https://rollupjs.org/troubleshooting/#warning-treating-module-as-external-dependency
@/models/Address (imported by "src/models/Company.ts")
created dist/types.d.ts in 207ms
Rollup config (simplified) adds this as the first plugin
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import typescript from "@rollup/plugin-typescript";
import dts from "rollup-plugin-dts";
import tsConfigPaths from "rollup-plugin-tsconfig-paths";
import peerDepsExternal from "rollup-plugin-peer-deps-external";
export default {
output: {
file: "dist/index.js",
format: "cjs",
},
plugins: [
tsConfigPaths(),
peerDepsExternal(),
resolve(),
commonjs(),
typescript({ tsconfig: "./tsconfig.json" }),
],
}
Hi!
While debugging rollup/plugins#1038 (comment), I stumbled upon an issue with your rollup plugin implementation. Basically you are doing this:
async resolveId(request: string, importer?: string) {
// ...
if (!moduleName) {
return this.resolve(request, importer, { skipSelf: true })
}
// ...
}
Unfortunately, there is a third parameter to resolveId
that @rollup/plugin-node-resolve
(and @rollup/plugin-commonjs
) depends upon, which you do not pass along. It is encodes whether we are resolving an entry point and additional custom plugin options which for the node-resolve plugin encode if we are resolving an import
or a require
. Depending on the package, this can lead to different (and wrong) resolutions.
See https://rollupjs.org/guide/en/#resolveid including the first example there, as well as https://rollupjs.org/guide/en/#custom-resolver-options for how custom options work, and why it is important for plugins to forward them.
The solution can be as simple as
async resolveId(request: string, importer: string | undefined, options: {isEntry: boolean, custom?: {[plugin: string]: any}) {
// ...
if (!moduleName) {
return this.resolve(request, importer, { skipSelf: true, ...options })
}
// ...
}
I would strongly advise to update your implementation to support this.
Maybe I'm missing something everybody else knows, but why does the example rollup config not use @rollup/plugin-typescript?
I'm trying to replace ttypescript with this plugin, but using this plugin doesn't appear to do anything
Hi!
Thanks so much for your effort here!
I'm getting an downstream effect via @graphql-codegen/cli on yarn3.
rollup-plugin-tsconfig-paths@npm:1.4.0 [3bb2f] doesn't provide typescript (p6dbbd), requested by typescript-paths
this is certainly no show stopper but i thought i'd mention it - i believe this should be as simple as adding your typescript version as a peer dependency in package.json.
Have a great day , and thanks again!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.