Skip to content

Default export not working in production env #3

Description

@kyrregjerstad

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/@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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions