-
Notifications
You must be signed in to change notification settings - Fork 7
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
No API object for function configuration #36
Comments
Since this module also does not resolve plugins and presets, a lot of the work can probably be replaced with |
I've also just hit this issue while trying to use https://github.com/tleunen/babel-plugin-module-resolver:
My workaround was to mock out the aspects of // If we aren't passed an api, mock one out here..
// Ref: https://babeljs.io/docs/en/config-files#apienv
const fakedApiObject = {
env: checkEnv => {
const envName = process.env.NODE_ENV || 'development'
if (typeof checkEnv === 'string') {
return checkEnv === envName
} else if (Array.isArray(checkEnv)) {
return checkEnv.includes(envName)
} else if (typeof checkEnv === 'function') {
return checkEnv(envName)
} else {
return envName
}
}
}
module.exports = (api = fakedApiObject) => {
// ..snip.. That ends up getting further, but then is dying on this (but that is likely more related to
Super cutting down the file it's failing on, it basically looks like this:
The It seems it may be related to it not being able to find my
Which goes away once i add the config back in : [
'module-resolver',
{
root: ['./spec/javascripts'],
alias: {
'test-helpers': './helpeaaarstestfoo',
},
},
], I'm not 100%.. but I think this could possibly also be solved by using Edit: Opened HeroProtagonist/eslint-plugin-module-resolver#44 RE: the 2nd part of my issue here with further details. |
I added support for config files with these lines. No value is passed into the config when it is called, so it makes sense that this happens. Do you guys know if babel exports this |
> require('@babel/core').loadPartialConfig({ rootMode: 'upward-optional' })
PartialConfig {
options: {
rootMode: 'upward-optional',
babelrc: false,
configFile: false,
passPerPreset: false,
envName: 'development',
cwd: '...',
root: '...',
filename: undefined,
plugins: [ [ConfigItem], [ConfigItem], [ConfigItem] ],
presets: [ [ConfigItem] ]
},
babelignore: undefined,
babelrc: undefined,
config: '.../babel.config.js'
} |
Unfortunately, I suspect there are probably exotic uses of I made an effort to catalogue some of the issues here: tleunen/eslint-import-resolver-babel-module#89 (comment) My recommendation, at this point, would be to try out a branch of |
I think that would look like option 4 in my comment. The |
Just in case it doesn't go without saying: none of this is meant as an attack. Thank you for your work on these projects. They've been immensely helpful to me. If I can help by prototyping any of the above, please let me know what makes sense to you. |
@tilgovi - No worries, I don't take it personally. I've been away from these projects for a long time because I'm not an active user/consumer of these anymore. So it's hard for me to find the time and the motivation to keep improving them. I'd like to update this library to use |
Cool. I'll let you know what I find. |
If a configuration file exports a function, it is not called with any arguments.
It should be called with an API object: https://babeljs.io/docs/en/config-files#config-function-api
The text was updated successfully, but these errors were encountered: