You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, this tool supports supplying a custom .babelrc file location via Jest global configuration (jest.globals['vue-jest'].babelRcFile), which is great.
However, .babelrc is not an option for us. Due to the fact that it is JSON, we cannot have any logic in the babel configuration. I tried using .babelrc.js, which babel supports, but the config loader assumes JSON and parses the file.
This generic solution opens up many more possibilities for how the tool can be used. For example, if the --config option is used with Jest, we are no longer restricted to JSON. This allows for the configuration to have logic:
This is especially powerful when used in conjunction with webpack, which can supply the same configuration to it's babel-loader to ensure functional parity when building the application.
This solution also allows for consumers to take advantage of the new configuration file resolution logic built-in to babel by using the root option:
Although I have not explored this option, it could provide an alternative approach to circumvent the current logic provided by third-party find-babel-contrib, which is not owned/maintained by the babel core team. I also found an open PR (#93) which indicates there are needs to make it better, or closer to the native behavior of babel.
The text was updated successfully, but these errors were encountered:
The problem
Currently, this tool supports supplying a custom
.babelrc
file location via Jest global configuration (jest.globals['vue-jest'].babelRcFile
), which is great.However,
.babelrc
is not an option for us. Due to the fact that it is JSON, we cannot have any logic in the babel configuration. I tried using.babelrc.js
, whichbabel
supports, but the config loader assumes JSON and parses the file.Additionally, we have moved to the new project-wide configuration file (
babel.config.js
) which is recommended by babel for our use-case, and exports a function instead of an object.The solution
expand the global jest configuration for
vue-jest
to support arbitrary babel options:This generic solution opens up many more possibilities for how the tool can be used. For example, if the --config option is used with Jest, we are no longer restricted to JSON. This allows for the configuration to have logic:
It can also be used to support the configFile option to use a project-wide configuration file (
babel.config.js
), e.g.:This configuration file exports a function that can use the config function API and returns babel options:
This is especially powerful when used in conjunction with
webpack
, which can supply the same configuration to it'sbabel-loader
to ensure functional parity when building the application.This solution also allows for consumers to take advantage of the new configuration file resolution logic built-in to babel by using the
root
option:Although I have not explored this option, it could provide an alternative approach to circumvent the current logic provided by third-party find-babel-contrib, which is not owned/maintained by the babel core team. I also found an open PR (#93) which indicates there are needs to make it better, or closer to the native behavior of
babel
.The text was updated successfully, but these errors were encountered: