Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

refactor: improve external module render for libraryType: module #19416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: main
Choose a base branch
Loading
from

Conversation

JSerFeng
Copy link
Contributor

@JSerFeng JSerFeng commented Apr 11, 2025

What kind of change does this PR introduce?

馃毀 WIP...

improve output for external module of library.type: module

Before:

import * as __WEBPACK_EXTERNAL_MODULE_external from 'external'
__WEBPACK_EXTERNAL_MODULE_external.foo;

This PR:

import { foo } from 'external'
foo;

ExternalModule is imported though InitFragment, which will insert a namespace import, but user may want to keep the code as is

// input
import { foo } from 'external'
foo;
// output
import * as __WEBPACK_EXTERNAL_MODULE_external from 'external'
__WEBPACK_EXTERNAL_MODULE_external.foo;

As we know the exportsInfo, we can use them to improve the output.

If exportsInfo.getUsedExports() equals:

  • true: used unknown exports from external module, fallback to namespace import like before
  • Set<string>: we know exactly used exports from external module, render them, we should also insert the exported specifier into ConcatenationScope.allUsedNames to avoid conflicts

Did you add tests for your changes?

WIP...

Does this PR introduce a breaking change?

No

What needs to be documented once your changes are merged?

@JSerFeng JSerFeng changed the title refactor: named imports from external module refactor: improve external module render for libraryType: module Apr 11, 2025
@JSerFeng JSerFeng force-pushed the refactor/improve-external-module-exports branch from 63a0edb to 2ad9415 Compare April 15, 2025 11:36
@JSerFeng JSerFeng marked this pull request as ready for review April 16, 2025 09:10
@JSerFeng JSerFeng marked this pull request as draft April 18, 2025 09:21
@alexander-akait
Copy link
Member

@JSerFeng Hello, do you need help here?

@JSerFeng
Copy link
Contributor Author

Hello, do you need help here?

Oh, I just meet the problem that InitFragments in ModuleConcatenationPlugin aren't analyzed. I'm trying another way, when I'm done I will request your review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.