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

Move the __non_webpack_import__ re-writing into the Babel plugin #17637

Conversation

Snuffleupagus
Copy link
Collaborator

Note how we're using custom __non_webpack_import__-calls in the code-base, that we replace during the post-processing stage of the build, to be able to write import-calls that Webpack will leave alone during parsing.
This work-around is necessary since we let Babel discards all comments, given that we generally don't need/want them in the builds, hence why we cannot utilize /* webpackIgnore: true */-comments in the source-code.

After the changes in PR #17563 it thus seems to me that we should be able to just move this re-writing into the Babel plugin instead.


/cc @nicolo-ribaudo Since my knowledge of Babel is somewhat limited: Can you please check if this re-writing makes sense, or if there's a better/nicer way to implement this?

@Snuffleupagus Snuffleupagus force-pushed the babel-plugin-__non_webpack_import__ branch 2 times, most recently from c58a721 to a15cc7f Compare February 8, 2024 17:16
Copy link
Contributor

@timvandermeij timvandermeij left a comment

Choose a reason for hiding this comment

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

Looks good to me; I like the overall simplification here and that all rewriting now happens in a single Babel plugin. Let's await Nicolò's review before merging to make sure I haven't missed anything here or to see if there is an even better way to do this. Thanks!

Copy link
Contributor

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

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

As an alternative, you could make Babel not discard comments by default and make the plugin drop all comments except for the ones you are interested in.

external/builder/babel-plugin-pdfjs-preprocessor.mjs Outdated Show resolved Hide resolved
@Snuffleupagus
Copy link
Collaborator Author

Snuffleupagus commented Feb 12, 2024

As an alternative, you could make Babel not discard comments by default and make the plugin drop all comments except for the ones you are interested in.

@nicolo-ribaudo That could be a better idea, however I'm not entirely sure how to implement that.
Based on what I've found online (with admittedly quick searching), there doesn't appear to be a "simple" way to access all comments short of parsing every single node?


Also, thanks a lot for your help/feedback on these PRs!

Note how we're using custom `__non_webpack_import__`-calls in the code-base, that we replace during the post-processing stage of the build, to be able to write `import`-calls that Webpack will leave alone during parsing.
This work-around is necessary since we let Babel discards all comments, given that we generally don't need/want them in the builds, hence why we cannot utilize `/* webpackIgnore: true */`-comments in the source-code.

After the changes in PR 17563 it thus seems to me that we should be able to just move this re-writing into the Babel plugin instead.
@Snuffleupagus Snuffleupagus force-pushed the babel-plugin-__non_webpack_import__ branch from a15cc7f to 4ab0ad3 Compare February 12, 2024 09:50
@Snuffleupagus
Copy link
Collaborator Author

/botio test

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.193.163.58:8877/d354cb37d3d987b/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.241.84.105:8877/e22e7a68d4ed43d/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/e22e7a68d4ed43d/output.txt

Total script time: 25.03 mins

  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: FAILED
  different ref/snapshot: 15
  different first/second rendering: 1

Image differences available at: http://54.241.84.105:8877/e22e7a68d4ed43d/reftest-analyzer.html#web=eq.log

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/d354cb37d3d987b/output.txt

Total script time: 39.72 mins

  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: FAILED
  different ref/snapshot: 3

Image differences available at: http://54.193.163.58:8877/d354cb37d3d987b/reftest-analyzer.html#web=eq.log

@Snuffleupagus Snuffleupagus marked this pull request as ready for review February 14, 2024 21:20
@Snuffleupagus
Copy link
Collaborator Author

While it may be possible to improve this further, as outlined in #17637 (review), even as-is this patch is an improvement since it gets rid of manual post-processing and thus simplifies the build process.

Landing with the previous r+, since the review comment above has been addressed.

@Snuffleupagus Snuffleupagus merged commit dbda3ec into mozilla:master Feb 14, 2024
9 checks passed
@Snuffleupagus Snuffleupagus deleted the babel-plugin-__non_webpack_import__ branch February 14, 2024 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants