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

User defined path shortcuts defined in tsconfig.json are not resolved in transpiled code #180

Open
mstn opened this issue Oct 23, 2019 · 9 comments · May be fixed by #241
Open

User defined path shortcuts defined in tsconfig.json are not resolved in transpiled code #180

mstn opened this issue Oct 23, 2019 · 9 comments · May be fixed by #241

Comments

@mstn
Copy link

mstn commented Oct 23, 2019

Hi there!

I am using shortcut paths in my tsconfig.json file. For example:

{
  "compilerOptions": {
    ...
    "paths": {
      "@app/*": ["./src/*"],
    }
  }
}

Paths are not expanded/resolved in transpiled code. This is a known feature/bug of Typescript microsoft/TypeScript#26722

There are a few workarounds as discussed in the issue above. One suggestion is to resolve the problem at the level of the output bundler (e.g. webpack and, in our case, this plugin).

I was just wondering if this plugin could resolve shortcuts before/after transpiling the code.

thanks

@marcosfede
Copy link

please add this!

@juank11memphis
Copy link

Any news on adding this feature?
Thanks :)

@theslyone
Copy link

theslyone commented May 15, 2020

Here's a quick fork off v1.1.7 to resolve this

npm install @theslyone/[email protected].

It's somewhat of a hack but works, ensure .serverless and .build directories are deleted before running

@maazmk
Copy link

maazmk commented Jul 27, 2020

any news on this issue?

@ThomasLabstep
Copy link

Same issue with baseUrl.
My absolute imports won't work.
For now I'll switch to relative imports because it's a small project.
But would be nice to have something more robust here.

@brothatru
Copy link

If you are using serverless-webpack (installed by default if you used sls create --template aws-nodejs-typescript)

In your webpack.config.js

// webpack.config.js
resolve: {
  extensions: ['.ts'],
  alias: {
    '@app': path.resolve(__dirname, './src'),
  },
},

// tsconfig.json
"baseUrl": "./src/",
"paths": {
    "@app/*": ["./*"]
},

Found in this thread

@jsefiani
Copy link

Will this feature be implemented?

@perrin4869 perrin4869 linked a pull request Jul 8, 2021 that will close this issue
@perrin4869
Copy link

Sent a PR implementing this is #241 ... but like my other PRs to this repo, there is no sign of it ever getting merged in...

@jasiene
Copy link

jasiene commented Oct 21, 2021

Would be super useful to have this! +1

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

Successfully merging a pull request may close this issue.

10 participants