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
Question: edge case with some undefined default exports? #87
Comments
Some more context: The wrapper I'm referencing follows the conventions listed here: https://nodejs.org/docs/latest-v16.x/api/packages.html#approach-1-use-an-es-module-wrapper // ./node_modules/pkg/package.json
{
"type": "module",
"exports": {
"import": "./wrapper.mjs",
"require": "./index.cjs"
}
} // ./node_modules/pkg/index.cjs
exports.name = 'value'; // <-- In the CJS file, there's no "default" export but... (see below)
// ./node_modules/pkg/wrapper.mjs
import cjsModule from './index.cjs'; // NodeJS imports the CJS module wholly without issue; equivalent to `import * as cjsModule from './index.cjs';
export const name = cjsModule.name; |
I think the question is: B.cjs But actually B has a B.mjs: import lib from './B.js' // this B.js has not been converted
export const { a: ..., b: ...} = lib |
Should the conversion be something like?: import * as pkg from "B"
const dfltExport = pkg.default || pkg // This way we always get a default in .mjs
export dfltExport |
I have a library that is attempting to import from socket.io. Here is the related issue: https://github.com/richardeschloss/nuxt-socket-io/issues/278
When I attempt to import and the run nuxt3, I encounter the following error:
Inside of wrapper.mjs, the first line seems to be the issue because ./build/engine.io.js does not seem to export a default:
My question is, I'm able to run the following successfully; i.e., inside wrapper, I can
console.log(lib)
:But when I run
nuxi dev
, I encounter the error. My follow up question is how does my command succeed when there appears to be no default? How can I get Nuxt to overcome this missing default?Fwiw, I'm on Node 16 (LTS), nuxt3.0.0-rc.12-27768618.05fd222, my nuxt config is pretty minimal, and package type set to "module" in package.json
The text was updated successfully, but these errors were encountered: