nuxt / module-builder

Complete solution to build and ship Nuxt modules.
MIT License
212 stars 22 forks source link

Build Module from `module.js` file #155

Closed ThornWalli closed 10 months ago

ThornWalli commented 10 months ago

Hello,

just trying to rewrite our module to "type": "module", because I wanted to resolve files in project .mjs to .js.

Unfortunately I got this error when running nuxt-module-build.

ℹ Building nuxt-speedkit                                                                                                                                  
TypeError: Cannot read properties of undefined (reading 'getFullText')
    at getModule (xxx/node_modules/rollup-plugin-dts/dist/rollup-plugin-dts.mjs:1610:26)
    at generateDtsFromTs (xxx/node_modules/rollup-plugin-dts/dist/rollup-plugin-dts.mjs:1683:32)
    at Object.transform (xxx/node_modules/rollup-plugin-dts/dist/rollup-plugin-dts.mjs:1706:38)
    at xxx/node_modules/rollup/dist/es/shared/node-entry.js:25336:40
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'PLUGIN_ERROR',
  plugin: 'commonjs--resolver',
  hook: 'resolveId',
  id: 'xxx/src/module.js',
  watchFiles: [ 'xxx/src/module.js' ]
}

Is it at all possible to use .js files instead of .mjs or .ts?

danielroe commented 10 months ago

It is indeed. In Nuxt we do it like this:

https://github.com/nuxt/nuxt/blob/574a5616b43d0caeddd97ddea3abf7703efec295/packages/nuxt/build.config.ts#L10

You can create a build.config.ts in your project and the module builder should respect it.