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)
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
.mjs
/.cjs
files for backwards compatibility.Background issue
At the moment, importing
vue-class-component
within an ESM context produces the following error:see https://github.com/nuxt/nuxt.js/issues/12050 closes nuxt/bridge#289