Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: improve FlagDependencyExportsPlugin for large JSON by depth #19058

Merged
merged 3 commits into from
Dec 19, 2024

Conversation

hai-x
Copy link
Contributor

@hai-x hai-x commented Dec 12, 2024

What kind of change does this PR introduce?

perf only for development mode

Fixes #18458

Did you add tests for your changes?
Yes

Does this PR introduce a breaking change?
No

What needs to be documented once your changes are merged?

Add two options to https://webpack.js.org/configuration/module/#moduleparser

for json

  • parse - Function that executes for a module source string and should return json-compatible data. Type ((input: string) => any), for For example we can use toml parser
const toml = require("toml");
 
module.exports = [
	{ 
		module: {
			rules: [
				{
					test: /\.toml$/,
					type: "json",
					parser: {
						parse(input) { 
							return toml.parse(input);
						}
					}
				}
			]
		}
	}
];
  • exportsDepth - The depth of json dependency flagged as exportInfo. In dev mode - 1, in prod - Infinity, Type number

@webpack-bot
Copy link
Contributor

webpack-bot commented Dec 12, 2024

For maintainers only:

  • This needs to be documented (issue in webpack/webpack.js.org will be filed when merged)
  • This needs to be backported to webpack 4 (issue will be created when merged)

Sorry, something went wrong.

@hai-x
Copy link
Contributor Author

hai-x commented Dec 12, 2024

Before

image

After

image

@hai-x hai-x force-pushed the hai-x/perf-json-flagDepExports branch from 973f619 to 38df65d Compare December 12, 2024 11:57
Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's make some improvements

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@hai-x hai-x force-pushed the hai-x/perf-json-flagDepExports branch from 583fa9b to 3de7b0d Compare December 13, 2024 17:24
@alexander-akait alexander-akait merged commit 3919c84 into webpack:main Dec 19, 2024
60 of 63 checks passed
@webpack-bot
Copy link
Contributor

I've created an issue to document this in webpack/webpack.js.org.

@alexander-akait
Copy link
Member

Thanks

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

Successfully merging this pull request may close these issues.

FlagDependencyExportsPlugin is slow with large JSON imports
3 participants