Skip to content

feat: fix webpack 5 compatibility issue in webpack.base.js#293

Merged
hsluoyz merged 2 commits intomasterfrom
copilot/fix-ci-error
Oct 12, 2025
Merged

feat: fix webpack 5 compatibility issue in webpack.base.js#293
hsluoyz merged 2 commits intomasterfrom
copilot/fix-ci-error

Conversation

Copy link
Contributor

Copilot AI commented Oct 12, 2025

Issue

The CI build was failing with the following error:

[webpack-cli] Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
 - configuration.node has an unknown property 'fs'. These properties are valid:
   object { __dirname?, __filename?, global? }

See: https://github.com/casbin/casbin.js/actions/runs/18438978328/job/52536865021

Root Cause

The webpack configuration in webpack.base.js was using the deprecated webpack 4 option node.fs: "empty". This option was removed in webpack 5 and is no longer supported.

Solution

Updated the webpack configuration to use the webpack 5 compatible approach by replacing:

node: {
  fs: "empty"
}

with:

resolve: {
  extensions: [ '.tsx', '.ts', '.js' ],
  fallback: {
    fs: false
  }
}

According to the webpack 5 migration guide, polyfills for Node.js core modules are no longer automatically included and must be explicitly configured via resolve.fallback.

Verification

  • ✅ All unit tests pass (13/13)
  • ✅ Lint passes successfully
  • ✅ TypeScript compilation succeeds
  • ✅ Webpack production build succeeds
  • ✅ Webpack development build succeeds
  • ✅ Prepack command (used in CI) succeeds

This minimal change ensures compatibility with webpack 5 while maintaining all existing functionality.

Original prompt

This section details on the original issue you should resolve

<issue_title>[bug] CI error needs to be fixed</issue_title>
<issue_description>See: https://github.com/casbin/casbin.js/actions/runs/18438978328/job/52536865021</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #292


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

…h resolve.fallback

Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix CI error in workflow execution Fix webpack 5 compatibility issue in webpack.base.js Oct 12, 2025
Copilot AI requested a review from hsluoyz October 12, 2025 04:28
@hsluoyz hsluoyz marked this pull request as ready for review October 12, 2025 04:44
@hsluoyz hsluoyz changed the title Fix webpack 5 compatibility issue in webpack.base.js feat: fix webpack 5 compatibility issue in webpack.base.js Oct 12, 2025
@hsluoyz hsluoyz merged commit 2f857e2 into master Oct 12, 2025
7 of 10 checks passed
github-actions bot pushed a commit that referenced this pull request Oct 12, 2025
# [1.0.0](v0.5.1...v1.0.0) (2025-10-12)

### Features

* fix CI error by removing --fix flag from lint script ([#297](#297)) ([4b6eccd](4b6eccd))
* fix CI error by requiring Node.js 20+ ([#300](#300)) ([b598665](b598665))
* fix CI error by updating to Node.js 20 ([1a3ce51](1a3ce51))
* fix CI error by updating to Node.js 20 in semantic-release ([#295](#295)) ([32fd7ae](32fd7ae))
* fix webpack 5 compatibility issue in webpack.base.js ([#293](#293)) ([2f857e2](2f857e2))
* regenerate yarn.lock ([18ff623](18ff623))
* trigger v1.0.0 major release ([#291](#291)) ([1153e94](1153e94))
* update Node.js version to 18 and 20 in CI ([#289](#289)) ([f14072a](f14072a))
* Update README badges ([#287](#287)) ([971e664](971e664))

### BREAKING CHANGES

* trigger v1.0.0 major release
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.

[bug] CI error needs to be fixed

3 participants