question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Default export not output as expected -- missing __esModule

See original GitHub issue

Current Behavior

TSDX doesn’t seem to have the expected output when building a package with a default export. The type definitions are output as expected, but the resulting .js file actually exports as { default: /* value */ }. I’ve created a minimal, reproducible example at rtbenfield/tsdx-default-export bootstrapped from tsdx create. This is my first time using TSDX and it is possible I am just doing something incorrectly.

In the repo mentioned above, I changed the sum function to be a default export, then added output.test.ts which imports directly from dist instead of src. output.test.ts logs the value of import sum from "../dist" and is showing sum to be { default: ... } instead of the actual function.

Expected behavior

The .js output files in dist can be consumed as default exports (ex. import sum from "my-module") if the source file utilized default exports.

Suggested solution(s)

Unsure, but willing to investigate if this is confirmed to be an issue. I know Webpack, but not Rollup, so it could be a good excuse for me to get some experience with it.

Additional context

Nothing relevant that I know of.

Your environment

Software Version(s)
TSDX 0.7.2
TypeScript 3.5.2
Browser N/A
npm/Yarn 6.9.0 / 1.16.0
Operating System Windows 10 Pro 1903

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:9
  • Comments:16 (3 by maintainers)

github_iconTop GitHub Comments

9reactions
TrySoundcommented, Oct 29, 2019

Or just don’t use this devil syntax. Named exports do the work better.

3reactions
nartccommented, Nov 12, 2019

Ran into this issue today. It’s not that I (and some others) want to use Default Export but because some other tools require Default Export to work, namely Mocha Custom Reporter.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Building CJS module from ESM with mixed named and default ...
A default export is a named export, it's just named default . ESM is built so that if you don't specify a name,...
Read more >
API - esbuild
This API call is used by the command-line interface if no input files are provided and the --bundle flag is not present. In...
Read more >
import - JavaScript - MDN Web Docs - Mozilla
Named and default imports are distinct syntaxes in JavaScript modules. Default import. Default exports need to be imported with the ...
Read more >
Modules • JavaScript for impatient programmers (ES2022 ...
Entities that are not exported are private to a module and can't be accessed from ... result of invocation is default-exported export default...
Read more >
eslint-plugin-import - npm
( no-unresolved ); Ensure named imports correspond to a named ... ( named ); Ensure a default export is present, given a default...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found