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.

Star re-exports (`import * as NS` / `export * as NS`) aren't wrapped with a `NS` name

See original GitHub issue

Bug report

I’ve used dts-bundle-generator to generate bundle of .d.ts for use on Monaco Editor and some wierd Typescript compiler that runs on GraalJS that i’ve made. I have 2 globals which are actually aliases to npm modules, which are Ramda and Cheerio, they worked great on some old .d.ts files, but when i’ve updated those libraries to its recent version, the code generation didn’t work.

Input code

import * as R from "ramda";
import * as cheerio from "cheerio";

export { R, cheerio }

Expected output

Something around this: https://gist.github.com/schleumer/3c0c7d468e050b2163760e7e4392d5cd, of course, those libs changed a lot and may be slightly different

Actual output

// Generated by dts-bundle-generator v5.4.0



export {
	 as R,
};

Additional context

I’ve made a custom script, something like:

const generated = generator.generateDtsBundle([
    {
        filePath: 'src/libs.d.ts'
    }
], {
  preferredConfigPath: './tsconfig.json',
  followSymlinks: true,
});

Also, with internal files, dts-bundle-generator works great, my only issue is with importing Ramda and Cheerio, don’t know if there’s something new that i’ve lost.

Thanks for the awesome library 😃

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:8
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
timocovcommented, Apr 10, 2021

Can’t we fail instead of producing wrong code?

If we can detect this then yes, I’d prefer to handle this and report an error for that for sure.

1reaction
RunDevelopmentcommented, Apr 10, 2021

it might produce wrong code

Can’t we fail instead of producing wrong code? People (e.g. I) rely on this being correct.

Renaming

Frankly, I would love to do a deep dive into this. This seems like an interesting problem but I don’t have the time right now. If this is still a problem in a few weeks from now, I’ll do a PR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Support ES `export * as ns from` form · Issue #4813 - GitHub
At first I thought this (the ECMAScript proposal) was a bad idea because the preponderance of existing export forms is a source of...
Read more >
THE COMMERCE CONTROL LIST - GovInfo
License Requirements Reason for Control: NS, AT, UN Control(s) Country Chart ... on certain commodities described in 0A987 if being exported, reexported, ...
Read more >
export - JavaScript - MDN Web Docs
The export declaration is used to export values from a JavaScript module. Exported values can then be imported into other programs with the ......
Read more >
Export and Import - The Modern JavaScript Tutorial
Export and import directives have several syntax variants. ... A module has either named exports or the default one.
Read more >
Modules • JavaScript for impatient programmers (ES2022 ...
This way of simulating modules, has several issues: Libraries in script files export and import functionality via global variables, which risks name clashes....
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