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

CommonJS issue for Nuxt SSR import #1414

Open
aonghas opened this issue Oct 26, 2024 · 2 comments
Open

CommonJS issue for Nuxt SSR import #1414

aonghas opened this issue Oct 26, 2024 · 2 comments

Comments

@aonghas
Copy link

aonghas commented Oct 26, 2024

Hi there, when using this with Nuxt 3 (SSR) it works fine in client but when deployed I get the following error:

import ChordSheetJS, { templateHelpers } from 'chordsheetjs';
                       ^^^^^^^^^^^^^^^
SyntaxError: Named export 'templateHelpers' not found. The requested module 'chordsheetjs' 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 'chordsheetjs';
const { templateHelpers } = pkg;

Any suggestions?

@aonghas
Copy link
Author

aonghas commented Oct 26, 2024

I think it's the same issue in #1180

Any chance templateHelpers can be added to the default export too?

Thanks!

@aonghas
Copy link
Author

aonghas commented Oct 28, 2024

I seem to have fixed this with the following config (in case it helps anyone else in future):

in nuxt.config:

export default defineNuxtConfig({

  build: {
    transpile: ["chordsheetjs"],
  },
})

When importing:

import * as ChordSheetJS from 'chordsheetjs';
const { templateHelpers } = ChordSheetJS;

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

No branches or pull requests

1 participant