Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

fix:module field in pkg and update example #15

Closed
wants to merge 3 commits into from

Conversation

bigbossx
Copy link

@bigbossx bigbossx commented Dec 1, 2021

hello, @antfu @kazupon

I Struggling with the issue #14 #10 when i run example in this project.
finally,i think maybe the problem is the lastest version 0.2.2 use incorrect module field dist/index.mjs in package.json

webpack/webpack#7482

when we use dist/index.mjs .mjs tries to be as compatible as possible to node.js
so ⬇️

// dist/index.mjs
import VueCompositionApi from "@vue/composition-api" // this import incorrect  commonjs file
// dist/index.mjs
import { computed, getCurrentInstance } from "@vue/composition-api";
// node_modules/@vue/composition-api/index.js ❌

BEA10BB8-A09D-4037-8011-269B80680497

when we use dist/index.js

// dist/index.js
var _compositionapi = require('@vue/composition-api');
// node_modules/@vue/composition-api/dist/vue-composition-api.mjs 🌈

46EAACB9-F331-427E-B14B-0E3B7A59E039

finally

so i modify something in package.json follow this link https://tsup.egoist.sh/#bundle-formats

image

is my understanding correct, maybe I'm missing something?

@bigbossx bigbossx closed this Mar 18, 2022
@bigbossx
Copy link
Author

bigbossx commented Mar 18, 2022

This only seems to happen with webpack4(use by vue-cli), I tested webpack2 with webpack5 and there is no problem with confusing module references. Also .mjs is probably an important way to distinguish module types in the future, so maybe my pr is a pointless fix, so close

for webpack4 we can fix it by
vuejs/composition-api#837

@kingyue737
Copy link
Contributor

Not a pointless fix! This package does not work in vitest as it doesn't support dual-packaging correctly, ref https://github.com/sheremet-va/dual-packaging.

I think you should reopen this PR

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants