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

feat: update to support babelConfig and tsConfig #111

Merged
merged 1 commit into from Oct 6, 2018

Conversation

justinhelmer
Copy link
Contributor

Fixes #110

@justinhelmer
Copy link
Contributor Author

justinhelmer commented Oct 3, 2018

Change needed locally to contribute: #108
Replaces the need for: #100
Potential alternative approach for: #93

@justinhelmer justinhelmer force-pushed the babel-config branch 2 times, most recently from 361918d to afcd2ac Compare October 3, 2018 04:08
@justinhelmer justinhelmer changed the title feat: update to support babel configuration object feat: update to support babel options configuration object Oct 3, 2018
@justinhelmer
Copy link
Contributor Author

justinhelmer commented Oct 3, 2018

You may notice the configuration option is called is babelOptions instead of babelConfig (which is used internally by vue-jest). I originally had called it babelConfig for consistency with the rest of the vue-jest source code, but changed it.

I decided to make the external interface align closer with the nomenclature used by other community tools, including babel itself.

@eddyerburgh
Copy link
Member

This looks great, I have some thoughts on the API. I think the babelOptions object should support a string path or an object of options, similar to ts-jest tsConfig option, so it would look like this:

{
  "jest": {
    "globals": {
      "vue-jest": {
        "babelOptions": {
          "presets": [
            [
              "env",
              {
                "useBuiltIns": "entry",
                "shippedProposals": true
              }
            ]
          ],
          "plugins": [
            "syntax-dynamic-import"
          ],
          "env": {
            "test": {
              "plugins": [
                "dynamic-import-node"
              ]
            }
          }
        }
      }
    }
  }
}

Or

{
  "jest": {
    "globals": {
      "vue-jest": {
        "babelOptions":  "relative/path/to/file"
      }
    }
  }
}

Also we need full tests to check that both API options work. Other than that, looks great :)

Copy link
Member

@eddyerburgh eddyerburgh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the API to match the ts-jest API, and add tests (not just unit) to check that both API options work. Other than that, looks great :)

@justinhelmer
Copy link
Contributor Author

justinhelmer commented Oct 3, 2018

@eddyerburgh - To match the ts-jest API, it would result in a breaking change to the current default logic for vue-jest.

From the docs:

The option is babelConfig and it works pretty much as the tsConfig option, except that it is disabled by default. Here is the possible values it can take:

false: the default, disables the use of Babel
true: enables Babel processing. ts-jest will try to find a .babelrc, .babelrc.js file or a babel section in the package.json file of your project and use it as the config to pass to babel-jest processor.
{ ... }: inline Babel options. You can also set this to an empty object ({}) so that the default Babel config file is not used.

Currently, even if no configuration is provided, the default fallback logic for vue-jest is to search for babel config. This would equate to babelConfig: true as the default behavior given the changes.

So the question is,

  1. Do you want me to proceed with matching the API exactly, including default behavior? This may need to result in a major version bump. Not sure if you want to go down this route.

  2. Do you want me to match the API with the one difference being the default behavior of true vs false?

  3. What about the current babelRcFile config? If babelConfig also supports a string representation as a path to a babel config file, then babelRcFile would be repetitive. Are you suggesting removing this option as well or leaving it as-is? If removing it, that would definitely dictate a major version bump.

Also, can you clarify what you mean by "not just unit tests"? It looks to me like that's all there is

@justinhelmer justinhelmer force-pushed the babel-config branch 2 times, most recently from 9555e0d to 685eaf2 Compare October 4, 2018 01:53
Copy link
Contributor Author

@justinhelmer justinhelmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested changed done, please see comments relating to final solution.

I rebased against master to get #108 which is why the "Review Changes" doesn't link to the original commit.

@justinhelmer justinhelmer force-pushed the babel-config branch 2 times, most recently from 03aa01e to 1a1d560 Compare October 4, 2018 02:05
@eddyerburgh
Copy link
Member

Do you want me to proceed with matching the API exactly, including default behavior? This may need to result in a major version bump. Not sure if you want to go down this route.

  1. Not exactly, we should default to true

  2. Do you want me to match the API with the one difference being the default behavior of true vs false?

Yes

  1. What about the current babelRcFile config? If babelConfig also supports a string representation as a path to a babel config file, then babelRcFile would be repetitive. Are you suggesting removing this option as well or leaving it as-is? If removing it, that would definitely dictate a major version bump.

I think we should deprecate the option as part of this work. To deprecate it, we need to remove it from the docs and add a warning when the method is called (without removing functionality).

I also think we should keep the API the same between tsConfig and babelConfig. Could you also deprecate the tsConfigFile option, and add a new tsConfig file option that behaves the same way?

Sorry for the amount of work, but you highlighted an issue with our globals design and I think we should address it now. Also, the next release will be a major due to this PR which changes the behavior of the babelrc lookup

@justinhelmer
Copy link
Contributor Author

justinhelmer commented Oct 4, 2018

Sure, no worries. I was coming to the same conclusion.

@justinhelmer
Copy link
Contributor Author

Requested changes in place.

Build will fail, because there is a prerequisite on #113

@justinhelmer justinhelmer changed the title feat: update to support babel options configuration object feat: update to support babelConfig and tsConfig Oct 5, 2018
@justinhelmer
Copy link
Contributor Author

@eddyerburgh - rebased against #113; should be good to merge.

@justinhelmer justinhelmer force-pushed the babel-config branch 2 times, most recently from fff7ba9 to 4daf24a Compare October 5, 2018 16:28
- babelConfig/tsConfig can take a boolean (config file lookup),
  object (inline config options), or string (path to config file)
- deprecated babelRcFile and tsConfigFile options
- Matches ts-jest API for babelConfig/tsConfig, with the exception
  that the default behavior for babelConfig is switched (enabled)
- Not a breaking change
Copy link
Member

@eddyerburgh eddyerburgh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work :)

@eddyerburgh eddyerburgh merged commit 4ac913d into vuejs:master Oct 6, 2018
@eddyerburgh
Copy link
Member

Hey @justinhelmer I decided that we should just let ts-jest and babel-jest handle compiling, like you suggested. Would you like to work on ts-jest integration?

@justinhelmer
Copy link
Contributor Author

@eddyerburgh - I believe you are referring to #114 .

Unfortunately I don't have the bandwidth right now to take on this challenge. It might change in the future if someone else doesn't take this on, but I don't want to be a bottleneck for delivery.

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

Successfully merging this pull request may close these issues.

None yet

2 participants