Skip to content
This repository has been archived by the owner on Jul 10, 2021. It is now read-only.

Import paths / file names with "type extensions" do not work. #3

Open
ChristianUlbrich opened this issue Mar 24, 2021 · 2 comments
Open
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@ChristianUlbrich
Copy link

ChristianUlbrich commented Mar 24, 2021

If an import contains additional dots, i.e if you are using a _"type exentensions"_™ this plugin will not add the actual extensions.

import { somethingBackFromOther } from '../lib/something.lib'should be transformed to import { somethingBackFromOther } from '../lib/something.lib.js', but it stays untouched.

However those filenames are quite common in a lot of frameworks (i.e. component.style.ts, component.test.ts, ...), actually the default extension for Jest tests is test.js (and thus in typescript test.ts).

I have added test cases at least for the imports at https://github.com/ChristianUlbrich/babel-plugin-add-import-extension that will fail.

This needs some consideration on how to combine this with the ability to replace an extension. I skimmed through the code and for me personally it is pretty dense (asi, nested destructuring, no comments, ...) so I can't come up with an easy fix w/o re-writing larger parts of it. Maybe @karlprieb can fix this in an instant. :)

@karlprieb
Copy link
Owner

Hey @ChristianUlbrich thank you reaching out!
I'll take a look on that this week :)

@karlprieb karlprieb added bug Something isn't working good first issue Good for newcomers labels Mar 24, 2021
@karlprieb
Copy link
Owner

Sorry @ChristianUlbrich i didn't have time to fix this, can you open a PR adding the test cases? I'll probaly continue the work from your branch :)
Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants