Default export not working in production env
kyrregjerstad opened this issue · comments
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:
- Import the
naevner
function into another TypeScript/JavaScript file usingimport naevner from "@samhaeng/naevner
.; - The function works as expected in the dev env
- Build the app with Vite
- Open the build preview
- 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/@samhaeng+naevner@1.0.5/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!