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!: use cjs/mjs extensions for cjs/esm builds #571

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

danielroe
Copy link
Member

@danielroe danielroe commented Oct 16, 2021

Summary

This PR proposes using .cjs and .mjs instead of the current .common.js and .esm.js extensions. That allows usage of this library in a native Node module context.

Notes

  • As is, this is a breaking change as it changes the packaging expectations. As v8 is still in a preview state, I thought that might be acceptable. If not, I can add stubs that re-export these .mjs/.cjs files for backwards compatibility.

Background issue

At the moment, importing vue-class-component within an ESM context produces the following error:

/project/node_modules/vue-class-component/dist/vue-class-component.esm-bundler.js:6
import { ref, proxyRefs } from 'vue';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:1001:16)
    at Module._compile (internal/modules/cjs/loader.js:1049:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14)
    at ModuleWrap.<anonymous> (internal/modules/esm/translators.js:199:29)
    at ModuleJob.run (internal/modules/esm/module_job.js:169:25)
    at async Loader.import (internal/modules/esm/loader.js:177:24)
    at async __instantiateModule__ (file:///project/.nuxt/dist/server/server.mjs:2180:3)

see nuxt/nuxt#12050
closes nuxt/bridge#289

@danielroe danielroe changed the title chore: use cjs/mjs extensions for cjs/esm builds build!: use cjs/mjs extensions for cjs/esm builds Oct 16, 2021
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.

@vueuse/core integration
1 participant