codex-team / icons

Dozens of cute svg icons made with love by CodeX for your projects. No dependencies required. Free to use and share.
MIT License
39 stars 15 forks source link

Problem with using nuxt.js #11

Closed slaveeks closed 1 year ago

slaveeks commented 1 year ago

When I use the following commands for building app, which uses icons package, everything is okay:

nuxt build

But if I use this command for building:

nuxt generate

I face with this error:

[nuxt] [request error] Named export 'IconMarker' not found. The requested module 'file:///Users/user/Desktop/CodeX/editorjs.io/node_modules/@codexteam/icons/dist/index.umd.js' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'file:///Users/user/Desktop/CodeX/editorjs.io/node_modules/@codexteam/icons/dist/index.umd.js';
const { IconMarker, IconStar } = pkg;
talyguryn commented 1 year ago

You might need to transpile library according Nuxt docs: https://nuxt.com/docs/guide/concepts/esm/#transpiling-libraries

Add build section to your nuxt.config.ts file:

import { defineNuxtConfig } from 'nuxt'

export default defineNuxtConfig({
    // ...

+    build: {
+      transpile: ['@codexteam/icons']
+    },
})    

If it will be a common problem, we can upgrade the readme with this tip.