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

Default export not working in production env #3

Open
kyrregjerstad opened this issue May 30, 2023 · 0 comments
Open

Default export not working in production env #3

kyrregjerstad opened this issue May 30, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@kyrregjerstad
Copy link

Description:
I have been experiencing difficulties while trying to import the naevner function from your TypeScript module. I believe there might be an issue with the way the function is exported.

Steps to Reproduce:

  1. Import the naevner function into another TypeScript/JavaScript file using import naevner from "@samhaeng/naevner.;
  2. The function works as expected in the dev env
  3. Build the app with Vite
  4. Open the build preview
  5. Observe the error in the console:

TypeError: naevner is not a function

Expected Behavior:
The naevner function should be successfully imported and usable in the build without throwing any errors.

Actual Behavior:
Currently, an error is thrown.

Workaround:
The current workaround I am using is to add the .default to the export as follows:

// node_modules/.pnpm/@[email protected]/node_modules/@samhaeng/naevner/dist/index.js
'use strict'

if (process.env.NODE_ENV === 'production') {
  module.exports = require('./naevner.cjs.production.min.js').default
} else {
  module.exports = require('./naevner.cjs.development.js').default
}

Additional Information:

  • TypeScript version: 5.0.4
  • Node.js version: 18.16.0
  • Build tool: Vite 4.3.0

Thanks for creating such a neat little tool!

@filipjakobsen filipjakobsen added the bug Something isn't working label May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants