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.

Preserve star exports for externalized dependencies in module output

See original GitHub issue

Bug report

What is the current behavior? When code contains exports from externalized libraries, the export statements are not preserved in output when they should be.

If the current behavior is a bug, please provide the steps to reproduce. Simple isolated repro (with details in the README): https://github.com/dzearing/test-webpack-esm

We bundle a simple entry point which contains:

export * from '@fluentui/utilities';

We turn on output.library.type="module" in the webpack config and mark the library as external. The bundle preserved should still emit the export. Instead it contains a bunch of unexpected content:

import*as e from"@fluentui/utilities";var r={d:(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r)};r.d({},{});

What is the expected behavior? The output should match the input and export * from the library.

webpack version: 5.67.0 Node.js version: 16.13.1 Operating System: Windows 11

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
dzearingcommented, Jan 31, 2022

Thanks @alexander-akait for the input and help. I’ve adjusted the title to fit more; either we can use this to track the specific ask, or close if it’s already tracked in the module support issue.

1reaction
alexander-akaitcommented, Jan 31, 2022

I understand what you want to achieve, but currently only one workaround - named export

Read more comments on GitHub >

github_iconTop Results From Across the Web

Package exports - webpack
The exports field in the package.json of a package allows to declare which module should be used when using module requests like import...
Read more >
Requiring modules in Node.js: Everything you need to know
Node uses two core modules for managing module dependencies: The require module, which appears to be available on the global scope — no...
Read more >
Node Modules at War: Why CommonJS and ES ... - Code Red
CJS scripts use require() and module.exports ; ESM scripts use import and export . ESM and CJS are completely different animals.
Read more >
What is the difference between "Module Dependencies" and ...
jar and dependent libraries into output root. This way library archives will be copied along with created .jar. You also need to create...
Read more >
CLI options - Terragrunt
terragrunt plan terragrunt apply terragrunt output terragrunt destroy # etc ... If you have a stack of Terragrunt modules with dependencies between ...
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