Skip to content

v1.1.2 no longer transforming paths #13

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

Closed
sbmw opened this issue May 21, 2019 · 10 comments
Closed

v1.1.2 no longer transforming paths #13

sbmw opened this issue May 21, 2019 · 10 comments
Labels
Bug Something isn't working

Comments

@sbmw
Copy link

sbmw commented May 21, 2019

Hi, thanks for this excellent plugin.

Unfortunately something seems to have stopped working (for me at least) in v1.1.2.

I've played around with incremental updates and believe the issue is in 73dd832 / "fix: type only import not deleted from result file"

Specifically this change:

image

My paths are set as follows:

    "paths": {
        "me/*": ["src/*"]
    },

An import looks like:

import { FooViewModel } from "me/viewModels/fooViewModel";

For now I can just use 1.1.0. Please let me know if there's any further info I can provide.

@anion155
Copy link
Contributor

anion155 commented May 21, 2019

Since 1.1.1 this module does not interrupt typescript's logic of module importing. So if you do not use FooViewModel, or if FooViewModel is type and you are waiting for import side effects on runtime, it will not work. Try to compile your code with original compiler and see if 'me/viewModels/fooViewModel' import is included. If it does, please provide some more info about your modules.

@anion155
Copy link
Contributor

For side effect imports usually used:

import "something";

@anion155
Copy link
Contributor

@sbmw So, was this the case when you wanted "import side effects" or is this a bug?

@sbmw
Copy link
Author

sbmw commented May 22, 2019

@anion155 Thanks for the help, but no I'm not using side effect imports and I believe this is a bug.

I've put together a very basic demo to show this in action: https://github.com/sbmw/transformdemo

One thing I have discovered: I had "module": "esnext" in my tsconfig. With that set, paths are not transformed in the output .js or .d.ts. If that is changed to "module": "commonjs" the .js file has its path correctly transformed.

However, the paths in output .d.ts declaration files are not transformed. If you were to consume the demo repo above as a package in another project you would get a compilation error like import { ApiResponseViewModel } from "me/viewModels/apiResponseViewModel".

https://github.com/sbmw/transformdemo/blob/master/dist/ajax/fetchHandler.d.ts for reference.

@anion155
Copy link
Contributor

About .d.ts read this #4
Will investigate about "module" configuration. Thanks

@sbmw
Copy link
Author

sbmw commented May 22, 2019

Thanks.

Re .d.ts, yes I know that and if you see my tsconfig you'll see I have danielpza's solution in place:

https://github.com/sbmw/transformdemo/blob/master/tsconfig.json

"plugins": [
  { "transform": "typescript-transform-paths" },
  { "transform": "typescript-transform-paths", "afterDeclarations": true }
]

But it is no longer working.

@anion155
Copy link
Contributor

Ok, will look into this.

@danielpza
Copy link
Member

@anion155 , I checked and it do stopped working when we changed from ts.updateImportDeclaration to node.moduleSpecifier.text = file;

I think we'll have to replicate the way typescript filters declarations as you originally did in #14. Do you still have a previous version of that PR?

@anion155
Copy link
Contributor

@danielpza git does not delete anything before gc ))

@danielpza danielpza added the Bug Something isn't working label May 24, 2019
@danielpza
Copy link
Member

@sbmw the fix is up in v1.1.3, I tested it in your demo https://github.com/sbmw/transformdemo and it worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants