Skip to content

Conversation

@adamstankiewicz
Copy link
Member

@adamstankiewicz adamstankiewicz commented Mar 28, 2025

The release of 14.4.0 to make Webpack and ESlint aware of paths defined in tsconfig.json breaks MFEs that have not yet adopted TypeScript, as described here. If a project does't define tsconfig.json, tsconfig-paths-webpack-plugin will unexpectedly throw an error due to the missing file.

> @edx/frontend-app-learner-dashboard@0.0.1 build
> fedx-scripts webpack

Running with resolved config:
/home/runner/work/frontend-app-learner-dashboard/frontend-app-learner-dashboard/webpack.prod.config.js

[webpack-cli] Failed to load '/home/runner/work/frontend-app-learner-dashboard/frontend-app-learner-dashboard/webpack.prod.config.js' config
[webpack-cli] Error: ENOENT: no such file or directory, stat 'tsconfig.json'
    at Object.statSync (node:fs:1[6](https://github.com/openedx/frontend-app-learner-dashboard/actions/runs/14122223957/job/39564410662?pr=569#step:8:7)67:25)
    at resolveConfigPath (/home/runner/work/frontend-app-learner-dashboard/frontend-app-learner-dashboard/node_modules/tsconfig-paths-webpack-plugin/node_modules/tsconfig-paths/lib/tsconfig-loader.js:56:12)
    at loadSyncDefault (/home/runner/work/frontend-app-learner-dashboard/frontend-app-learner-dashboard/node_modules/tsconfig-paths-webpack-plugin/node_modules/tsconfig-paths/lib/tsconfig-loader.js:33:22)
    at tsConfigLoader (/home/runner/work/frontend-app-learner-dashboard/frontend-app-learner-dashboard/node_modules/tsconfig-paths-webpack-plugin/node_modules/tsconfig-paths/lib/tsconfig-loader.js:2[7](https://github.com/openedx/frontend-app-learner-dashboard/actions/runs/14122223957/job/39564410662?pr=569#step:8:8):22)
    at configLoader (/home/runner/work/frontend-app-learner-dashboard/frontend-app-learner-dashboard/node_modules/tsconfig-paths-webpack-plugin/node_modules/tsconfig-paths/lib/config-loader.js:2[8](https://github.com/openedx/frontend-app-learner-dashboard/actions/runs/14122223957/job/39564410662?pr=569#step:8:9):22)
    at Object.loadConfig (/home/runner/work/frontend-app-learner-dashboard/frontend-app-learner-dashboard/node_modules/tsconfig-paths-webpack-plugin/node_modules/tsconfig-paths/lib/config-loader.js:8:12)
    at loadConfig (/home/runner/work/frontend-app-learner-dashboard/frontend-app-learner-dashboard/node_modules/tsconfig-paths-webpack-plugin/lib/plugin.js:86:36)
    at new TsconfigPathsPlugin (/home/runner/work/frontend-app-learner-dashboard/frontend-app-learner-dashboard/node_modules/tsconfig-paths-webpack-plugin/lib/plugin.js:35:26)
    at Object.<anonymous> (/home/runner/work/frontend-app-learner-dashboard/frontend-app-learner-dashboard/node_modules/@openedx/frontend-build/config/webpack.common.config.js:50:7)
    at Module._compile (node:internal/modules/cjs/loader:152[9](https://github.com/openedx/frontend-app-learner-dashboard/actions/runs/14122223957/job/39564410662?pr=569#step:8:10):14) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'stat',
  path: 'tsconfig.json'
}

This PR ensures tsconfig-paths-webpack-plugin is only included in webpack.common.config.js if a root tsconfig.json file exists for a project.

Testing Instructions

  1. Run npm run build for the example MFE app included with this project with the included ./example/tsconfig.json file.
  2. Observe it builds successfully.
  3. Temporarily delete the ./example/tsconfig.json file, and change the @src/App import to ./App.
  4. Re-run npm run build for the example MFE.
  5. Observe it will now build successfully; previously, it would not.

@adamstankiewicz adamstankiewicz merged commit 3c80898 into openedx:master Mar 28, 2025
4 checks passed
@codecov
Copy link

codecov bot commented Mar 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (cd49b15) to head (8457337).
Report is 1 commits behind head on master.

Additional details and impacted files
@@      Coverage Diff      @@
##   master   #643   +/-   ##
=============================
=============================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@adamstankiewicz adamstankiewicz deleted the ags/tsconfig-paths-optional-hotfix branch March 28, 2025 11:58
@openedx-semantic-release-bot

🎉 This PR is included in version 14.4.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@openedx-semantic-release-bot

🎉 This PR is included in version 15.0.0-alpha.27 🎉

The release is available on:

Your semantic-release bot 📦🚀

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