Giter Site home page Giter Site logo

typescript-paths's Introduction

typescript-paths's People

Contributors

lightyen avatar waleed-kh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

typescript-paths's Issues

allow file extension on the paths

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" ]
    }
  }
}

Rollup v3

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

Issue with resolving the paths that are at the same level

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" }),
    ],
  }

rollup-plugin-tsconfig-paths: Pass along resolve options in resolveId hook

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.

Example config using @rollup/plugin-typescript

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

yarn3 indicating a missing peer dependency of typescript.

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.