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

Add support for relative imports (e.g. using tsconfig's baseUrl) #9

Open
alalonde opened this issue May 2, 2022 · 1 comment
Open

Comments

@alalonde
Copy link

alalonde commented May 2, 2022

// Meh
import config from '../../../../../../../config';

// Awesome!
import config from '@cuteapp/config'; 

// or maybe even relatively from a specified root 
import config from 'config'; 

According to this, babel supports this, so it seems we should be able to support it here as well.

Would it be possible to just add an adjacent configuration to my .neutrinorc.js as a workaround for the time being?

@davidje13
Copy link
Owner

It would be nice to support this, but I don't know what the necessary tsconfig would be (baseUrl isn't for aliases like @cuteapp in your example; it's for specifying the root when using absolute paths)

If you find a configuration which works, I'd be happy to add support for it to the library. I seem to remember that tsc's ability to alias imports is pretty lacking though (I was investigating it for #6, which never got implemented due to these limitations, but maybe things have changed in the last year-and-a-bit)

If you want to try some stuff you can always set custom tsconfig like this:

const typescript = require('neutrinojs-typescript');

module.exports = {
  use: [
    typescript({ tsconfig: {
      compilerOptions: {
        /* arbitrary tsconfig here */
      },
    } }),
  ],
};

and you can customise Babel in the usual Neutrino way (though it seems people are having problems doing this with Neutrino even without TypeScript so you may hit difficulties)

If you do find a way to make it work, let me know and I'll look at integrating it into the library.

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

No branches or pull requests

2 participants