Skip to content

fix(runtime): add define constant to help downgrade non-esm project#3261

Merged
2heal1 merged 2 commits intomainfrom
fix/esm
Nov 26, 2024
Merged

fix(runtime): add define constant to help downgrade non-esm project#3261
2heal1 merged 2 commits intomainfrom
fix/esm

Conversation

@2heal1
Copy link
Copy Markdown
Member

@2heal1 2heal1 commented Nov 21, 2024

Description

  • add define constant to help downgrade non-esm project

The magic comment(webpackIgnore) will make rspack not downgrade the code , and @rsbuild/plugin-check-syntax will throw error . If users can make sure the project not use esm type module, they can set FEDERATION_ALLOW_NEW_FUNCTION by define plugin in build config , and skip the checker.

Related Issue

reproduce repo: https://github.com/2heal1/rsbuild-demo/tree/chore/syntax-check

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.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Nov 21, 2024

🦋 Changeset detected

Latest commit: 88968e1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 27 packages
Name Type
@module-federation/runtime Patch
@module-federation/modern-js Patch
@module-federation/devtools Patch
@module-federation/data-prefetch Patch
@module-federation/dts-plugin Patch
@module-federation/nextjs-mf Patch
@module-federation/node Patch
@module-federation/retry-plugin Patch
@module-federation/runtime-tools Patch
@module-federation/webpack-bundler-runtime Patch
@module-federation/bridge-react Patch
@module-federation/bridge-vue3 Patch
@module-federation/enhanced Patch
@module-federation/rspack Patch
@module-federation/rsbuild-plugin Patch
@module-federation/storybook-addon Patch
@module-federation/modernjsapp Patch
@module-federation/sdk Patch
@module-federation/managers Patch
@module-federation/manifest Patch
@module-federation/third-party-dts-extractor Patch
@module-federation/bridge-shared Patch
@module-federation/bridge-react-webpack-plugin Patch
@module-federation/error-codes Patch
@module-federation/esbuild Patch
@module-federation/utilities Patch
website-new Patch

Not sure what this means? Click here to learn what changesets are.

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

@netlify
Copy link
Copy Markdown

netlify bot commented Nov 21, 2024

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit 88968e1
🔍 Latest deploy log https://app.netlify.com/sites/module-federation-docs/deploys/674565e07f544e0008dc962d
😎 Deploy Preview https://deploy-preview-3261--module-federation-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Copy Markdown
Contributor

@squadronai squadronai bot left a comment

Choose a reason for hiding this comment

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

Summary

The pull request makes the following core changes to help downgrade non-ESM projects:

  • Adds a new define constant FEDERATION_ALLOW_NEW_FUNCTION to the packages/runtime/src/utils/load.ts file.
  • This constant is used to conditionally load the remote entry using a new Function constructor instead of the standard import() statement.
  • This helps bypass the @rsbuild/plugin-check-syntax error when the project is not using ESM modules.
  • The changes are accompanied by updates to the documentation and tests.
File Summaries
File Summary
packages/runtime/src/utils/load.ts The code changes introduce a new define constant FEDERATION_ALLOW_NEW_FUNCTION to help downgrade non-ESM projects. This constant is used to conditionally load the remote entry using a new Function constructor instead of the standard import() statement, which can help bypass the @rsbuild/plugin-check-syntax error when the project is not using ESM modules.

Copy link
Copy Markdown
Contributor

@squadronai squadronai bot left a comment

Choose a reason for hiding this comment

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

Incremental Review

Comments posted: 3

Configuration

Squadron Mode: essential

Commits Reviewed

13e94cd132c27589a23396925f7fdc6167d809ee...2cbc1bd52020e77d676c014c8d7d29bc757bd87c

Files Reviewed
  • packages/runtime/src/utils/load.ts
Files Ignored

These files were ignored due to the filter in the squadron.yaml file.

  • .changeset/dirty-bikes-report.md
  • packages/runtime/global.d.ts

@module-federation module-federation deleted a comment from squadronai bot Nov 21, 2024
@module-federation module-federation deleted a comment from squadronai bot Nov 21, 2024
@ScriptedAlchemy ScriptedAlchemy self-requested a review November 21, 2024 19:39
@2heal1 2heal1 merged commit a960c88 into main Nov 26, 2024
@2heal1 2heal1 deleted the fix/esm branch November 26, 2024 06:08
@2heal1 2heal1 mentioned this pull request Nov 26, 2024
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.

2 participants