Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
WIP: generate static property assignment exports
  • Loading branch information
JakobJingleheimer committed Dec 15, 2021
commit 6e244074d4cb9f06acac96e6d03979e2597e0a0c
15 changes: 13 additions & 2 deletions lib/library/AssignLibraryPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ class AssignLibraryPlugin extends AbstractLibraryPlugin {
* @param {LibraryContext<T>} libraryContext context
* @returns {Source} source with library export
*/
renderStartup(source, module, { chunk }, { options, compilation }) {
renderStartup(source, module, { moduleGraph, chunk }, { options, compilation }) {
const fullNameResolved = this._getResolvedFullName(
options,
chunk,
Expand All @@ -273,7 +273,18 @@ class AssignLibraryPlugin extends AbstractLibraryPlugin {
)
: "";
const result = new ConcatSource(source);
if (options.name ? this.named === "copy" : this.unnamed === "copy") {
if (options.export === 'static') {
const exportsInfo = moduleGraph.getExportsInfo(module);
for (const exportInfo of exportsInfo.orderedExports) {
if (!exportInfo.provided) continue;
result.add(
`module.exports.${exportInfo.name} = ${exportInfo.name};\n`
);
}
result.add(
`Object.defineProperty(module.exports, "__esModule", { value: true });\n`
);
} else if (options.name ? this.named === "copy" : this.unnamed === "copy") {
result.add(
`var __webpack_export_target__ = ${accessWithInit(
fullNameResolved,
Expand Down