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

build: add esm bundle #1990

Merged
merged 2 commits into from Aug 3, 2022
Merged

build: add esm bundle #1990

merged 2 commits into from Aug 3, 2022

Conversation

nieyuyao
Copy link
Contributor

@nieyuyao nieyuyao commented Aug 1, 2022

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Other information:

Provides an ESM bundle.

@netlify
Copy link

netlify bot commented Aug 1, 2022

Deploy Preview for vue-test-utils-v1 failed.

Name Link
🔨 Latest commit 838bb9a
🔍 Latest deploy log https://app.netlify.com/sites/vue-test-utils-v1/deploys/62e8c312a4e642000a445d8f

Copy link
Member

@lmiller1990 lmiller1990 left a comment

Choose a reason for hiding this comment

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

Cool, can you also add the exports field like so?

https://github.com/vuejs/test-utils/blob/main/package.json#L9-L15

Copy link
Member

@lmiller1990 lmiller1990 left a comment

Choose a reason for hiding this comment

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

Thanks, will do a release soon :)

@lmiller1990 lmiller1990 merged commit c6d28ef into vuejs:dev Aug 3, 2022
@nieyuyao nieyuyao deleted the build/esm-bundle branch August 3, 2022 02:57
Comment on lines +7 to +15
"exports": {
".": {
"import": {
"node": "./dist/vue-test-utils.js",
"require": "./dist/vue-test-utils.js",
"default": "./dist/vue-test-utils.esm.js"
}
}
},

Choose a reason for hiding this comment

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

Why was this added as-is, i.e. why with the import nesting? That breaks importing @vue/test-utils v1.3.1 in jest (non esm) for me with:

Cannot find module '@vue/test-utils' from '...'

    > 1 | import { createLocalVue } from '@vue/test-utils'

when I remove the import like this:

  "exports": {
    ".": {
      "node": "./dist/vue-test-utils.js",
      "require": "./dist/vue-test-utils.js",
      "default": "./dist/vue-test-utils.esm.js"
    }
  },

then it works again.

The comment that suggested to add the exports key was referencing this, i.e. the vue3 version of test-utils:

https://github.com/vuejs/test-utils/blob/main/package.json#L9-L15

There is no nested import there.

Maybe the following would be best?

  "exports": {
    ".": {
      "import": "./dist/vue-test-utils.esm.js",
      "require": "./dist/vue-test-utils.js",
      "default": "./dist/vue-test-utils.js"
    }
  },

That would be the most similar to what is done in vue/test-utils right now.

Copy link
Member

Choose a reason for hiding this comment

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

Uh oh, did not realize this broke things. I'll patch this right now.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Done
https://github.com/vuejs/vue-test-utils/releases/tag/v1.3.2

Gave it a quick test, seems okay, LMK if you run into any problems.

Choose a reason for hiding this comment

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

Thanks that fixed it!

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

3 participants