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

Add moduleParsed plugin hook #3813

Merged
merged 4 commits into from Oct 13, 2020
Merged

Add moduleParsed plugin hook #3813

merged 4 commits into from Oct 13, 2020

Conversation

lukastaegert
Copy link
Member

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

List any relevant issue numbers:

Description

This adds a new hook moduleParsed that is called for each module after the transform hook. This is needed to be notified once a cached module is available and will be useful to finally fix the caching for the commonjs plugin. Mainly, this hook will be used to resolve if a module is commonjs or ES both for cached and other modules.

moduleParsed

Type: (moduleInfo: ModuleInfo) => void

Kind: async, parallel

Previous Hook: transform where the currently handled file was transformed.

NextHook: resolveId and resolveDynamicImport to resolve all discovered static and dynamic imports in parallel if present, otherwise buildEnd.

This hook is called each time a module has been fully parsed by Rollup. See this.getModuleInfo for what information is passed to this hook.

In contrast to the transform hook, this hook is never cached and can be used to get information about both cached and other modules, including the final shape of the meta property, the code and the ast.

Note that information about imported modules is not yet available in this hook, and information about importing modules may be incomplete as additional importers could be discovered later. If you need this information, use the buildEnd hook.

@rollup-bot
Copy link
Collaborator

rollup-bot commented Oct 8, 2020

Thank you for your contribution! ❤️

You can try out this pull request locally by installing Rollup via

npm install rollup/rollup#parsed-plugin-hook

or load it into the REPL:
https://rollupjs.org/repl/?circleci=13200

@codecov
Copy link

codecov bot commented Oct 8, 2020

Codecov Report

Merging #3813 into master will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3813      +/-   ##
==========================================
- Coverage   97.05%   97.05%   -0.01%     
==========================================
  Files         185      185              
  Lines        6482     6477       -5     
  Branches     1877     1873       -4     
==========================================
- Hits         6291     6286       -5     
  Misses        101      101              
  Partials       90       90              
Impacted Files Coverage Δ
src/Bundle.ts 100.00% <ø> (ø)
src/utils/PluginDriver.ts 100.00% <ø> (ø)
src/utils/collapseSourcemaps.ts 90.00% <ø> (ø)
src/utils/transform.ts 100.00% <ø> (ø)
src/utils/traverseStaticDependencies.ts 100.00% <ø> (ø)
src/Chunk.ts 100.00% <100.00%> (ø)
src/ExternalModule.ts 100.00% <100.00%> (ø)
src/Graph.ts 100.00% <100.00%> (ø)
src/Module.ts 100.00% <100.00%> (ø)
src/ModuleLoader.ts 100.00% <100.00%> (ø)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 53493f6...0ac41a0. Read the comment docs.

@lukastaegert lukastaegert merged commit 22289f9 into master Oct 13, 2020
@lukastaegert lukastaegert deleted the parsed-plugin-hook branch October 13, 2020 17:58
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.

None yet

2 participants