Skip to content

feat(runtime): add webpack require and bundler-ignore accessors#4457

Open
ScriptedAlchemy wants to merge 43 commits intomainfrom
cursor/bundler-runtime-require-access-725d
Open

feat(runtime): add webpack require and bundler-ignore accessors#4457
ScriptedAlchemy wants to merge 43 commits intomainfrom
cursor/bundler-runtime-require-access-725d

Conversation

@ScriptedAlchemy
Copy link
Member

Description

Centralizes access to __webpack_require__ and dynamic webpackIgnore/vite-ignore imports into dedicated helpers. This prevents direct global references from being inlined or patched during bundling, allowing downstream packages to import these functionalities externally.

Specifically:

  • Introduced getWebpackRequire() and getWebpackRequireOrThrow() in @module-federation/webpack-bundler-runtime/accessor for safe __webpack_require__ access.
  • Created importWithBundlerIgnore() in @module-federation/sdk to encapsulate /* webpackIgnore: true */ /* @vite-ignore */ dynamic imports, avoiding dependency cycles.
  • Migrated existing direct __webpack_require__ and magic-comment dynamic import usages in runtime-core and utilities to use these new helpers.
  • Cleaned up one direct __webpack_require__ reference within webpack-bundler-runtime itself.

Related Issue

Addresses the need to provide stable, importable accessors for webpack runtime globals and magic-comment-driven dynamic imports, as discussed in the conversation.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated the documentation.

Open in Cursor Open in Web

@cursor
Copy link

cursor bot commented Feb 17, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@changeset-bot
Copy link

changeset-bot bot commented Feb 17, 2026

⚠️ No Changeset found

Latest commit: c885b33

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@netlify
Copy link

netlify bot commented Feb 17, 2026

Deploy Preview for module-federation-docs failed. Why did it fail? →

Name Link
🔨 Latest commit c885b33
🔍 Latest deploy log https://app.netlify.com/projects/module-federation-docs/deploys/69b0613a6d10f000084e4329

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 17, 2026

Open in StackBlitz

@module-federation/devtools

pnpm add https://pkg.pr.new/@module-federation/devtools@5e77f09

@module-federation/cli

pnpm add https://pkg.pr.new/@module-federation/cli@5e77f09

create-module-federation

pnpm add https://pkg.pr.new/create-module-federation@5e77f09

@module-federation/data-prefetch

pnpm add https://pkg.pr.new/@module-federation/data-prefetch@5e77f09

@module-federation/dts-plugin

pnpm add https://pkg.pr.new/@module-federation/dts-plugin@5e77f09

@module-federation/enhanced

pnpm add https://pkg.pr.new/@module-federation/enhanced@5e77f09

@module-federation/error-codes

pnpm add https://pkg.pr.new/@module-federation/error-codes@5e77f09

@module-federation/esbuild

pnpm add https://pkg.pr.new/@module-federation/esbuild@5e77f09

@module-federation/managers

pnpm add https://pkg.pr.new/@module-federation/managers@5e77f09

@module-federation/manifest

pnpm add https://pkg.pr.new/@module-federation/manifest@5e77f09

@module-federation/metro

pnpm add https://pkg.pr.new/@module-federation/metro@5e77f09

@module-federation/metro-plugin-rnc-cli

pnpm add https://pkg.pr.new/@module-federation/metro-plugin-rnc-cli@5e77f09

@module-federation/metro-plugin-rnef

pnpm add https://pkg.pr.new/@module-federation/metro-plugin-rnef@5e77f09

@module-federation/modern-js

pnpm add https://pkg.pr.new/@module-federation/modern-js@5e77f09

@module-federation/modern-js-v3

pnpm add https://pkg.pr.new/@module-federation/modern-js-v3@5e77f09

@module-federation/native-federation-tests

pnpm add https://pkg.pr.new/@module-federation/native-federation-tests@5e77f09

@module-federation/native-federation-typescript

pnpm add https://pkg.pr.new/@module-federation/native-federation-typescript@5e77f09

@module-federation/nextjs-mf

pnpm add https://pkg.pr.new/@module-federation/nextjs-mf@5e77f09

@module-federation/node

pnpm add https://pkg.pr.new/@module-federation/node@5e77f09

@module-federation/retry-plugin

pnpm add https://pkg.pr.new/@module-federation/retry-plugin@5e77f09

@module-federation/rsbuild-plugin

pnpm add https://pkg.pr.new/@module-federation/rsbuild-plugin@5e77f09

@module-federation/rspack

pnpm add https://pkg.pr.new/@module-federation/rspack@5e77f09

@module-federation/rspress-plugin

pnpm add https://pkg.pr.new/@module-federation/rspress-plugin@5e77f09

@module-federation/runtime

pnpm add https://pkg.pr.new/@module-federation/runtime@5e77f09

@module-federation/runtime-core

pnpm add https://pkg.pr.new/@module-federation/runtime-core@5e77f09

@module-federation/runtime-tools

pnpm add https://pkg.pr.new/@module-federation/runtime-tools@5e77f09

@module-federation/sdk

pnpm add https://pkg.pr.new/@module-federation/sdk@5e77f09

@module-federation/storybook-addon

pnpm add https://pkg.pr.new/@module-federation/storybook-addon@5e77f09

@module-federation/third-party-dts-extractor

pnpm add https://pkg.pr.new/@module-federation/third-party-dts-extractor@5e77f09

@module-federation/treeshake-frontend

pnpm add https://pkg.pr.new/@module-federation/treeshake-frontend@5e77f09

@module-federation/treeshake-server

pnpm add https://pkg.pr.new/@module-federation/treeshake-server@5e77f09

@module-federation/typescript

pnpm add https://pkg.pr.new/@module-federation/typescript@5e77f09

@module-federation/utilities

pnpm add https://pkg.pr.new/@module-federation/utilities@5e77f09

@module-federation/webpack-bundler-runtime

pnpm add https://pkg.pr.new/@module-federation/webpack-bundler-runtime@5e77f09

@module-federation/bridge-react

pnpm add https://pkg.pr.new/@module-federation/bridge-react@5e77f09

@module-federation/bridge-react-webpack-plugin

pnpm add https://pkg.pr.new/@module-federation/bridge-react-webpack-plugin@5e77f09

@module-federation/bridge-shared

pnpm add https://pkg.pr.new/@module-federation/bridge-shared@5e77f09

@module-federation/bridge-vue3

pnpm add https://pkg.pr.new/@module-federation/bridge-vue3@5e77f09

@module-federation/inject-external-runtime-core-plugin

pnpm add https://pkg.pr.new/@module-federation/inject-external-runtime-core-plugin@5e77f09

commit: 5e77f09

@github-actions
Copy link
Contributor

github-actions bot commented Feb 17, 2026

Bundle Size Report

7 package(s) changed, 34 unchanged.

Package Total dist Delta ESM gzip Delta
utils 125.2 kB +14.6 kB (+13.2%) 328 B no change
sdk 108.4 kB +3.8 kB (+3.6%) 8.1 kB no change
node 124.0 kB +830 B (+0.7%) 489 B no change
webpack-bundler-runtime 76.7 kB +213 B (+0.3%) 5.9 kB +21 B (+0.3%)
vue3-bridge 159.0 kB +143 B (+0.1%) 23.2 kB +17 B (+0.1%)
bridge-react 359.7 kB +126 B (+0.0%) 1.3 kB +1 B (+0.1%)
runtime-core 305.1 kB +83 B (+0.0%) 25.5 kB +1 B (+0.0%)

Total dist: 6.90 MB (+19.7 kB (+0.3%))
Total ESM gzip: 138.6 kB (+40 B (+0.0%))

@ScriptedAlchemy ScriptedAlchemy changed the title Bundler runtime require access feat(runtime): add webpack require and bundler-ignore accessors Feb 17, 2026
@ScriptedAlchemy ScriptedAlchemy marked this pull request as ready for review February 17, 2026 22:44
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e3de5a394f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Member Author

@ScriptedAlchemy ScriptedAlchemy left a comment

Choose a reason for hiding this comment

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

I found one regression in packages/utilities/src/utils/pure.ts: loadScript now resolves getWebpackRequireOrThrow() before checking whether the remote container is already present on globalScope. In non-webpack hosts with preloaded globals, this throws early (__webpack_require__ missing) instead of returning the existing container. Consider resolving webpack require only in the branch that actually calls webpackRequire.l(...).

Copy link
Member Author

Re-reviewed latest head ce7453a4cdaafc9363c9462cdb341fde4cddd768: one runtime regression still appears unresolved in packages/utilities/src/utils/pure.ts.

loadScript currently resolves getWebpackRequireOrThrow() before checking if globalScope[remoteGlobal] already exists. In non-webpack hosts with preloaded globals, this still throws early (__webpack_require__ missing) instead of returning the existing container. Please move webpack require resolution into the branch that actually calls webpackRequire.l(...).

@ScriptedAlchemy
Copy link
Member Author

@codex review the pr

Copy link
Member Author

Re-review on head f2ba7eb: loadScript in packages/utilities/src/utils/pure.ts still resolves getWebpackRequireOrThrow() before checking whether globalScope[remoteGlobal] already exists. In non-webpack hosts that preload the remote container on the global object, this now throws for missing __webpack_require__ and regresses loadScript/importDelegatedModule flows that intentionally skip script injection. Please defer webpack require resolution to the branch that actually calls webpackRequire.l(...).

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Nice work!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

cursoragent and others added 19 commits February 18, 2026 06:38
Resolve the dts-plugin TYPE-001 failure by correcting package entry paths for
workspace dependencies and updating RawSource usage for webpack typings.

Co-authored-by: Cursor <cursoragent@cursor.com>
Restore sdk and error-codes export paths to the filenames emitted by the
current build so CI package resolution no longer fails on these branches.

Co-authored-by: Cursor <cursoragent@cursor.com>
…e-require-access-725d

# Conflicts:
#	.changeset/twelve-forks-whisper.md
…e-require-access-725d

# Conflicts:
#	packages/sdk/project.json
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.

3 participants