Repository navigation
chore: load configuration files without eval - #4893
Conversation
TypeScript with module nodenext keeps import() in the CommonJS output, so eval is no longer needed to stop it turning into require(). Claude-Session: https://claude.ai/code/session_013FhutRFjuQemBzekJMYcqL
🦋 Changeset detectedLatest commit: 42cf33b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
This PR is packaged and the instant preview is available (4a88999). Install it locally:
npm i -D webpack-cli@https://pkg.pr.new/webpack-cli@4a88999
yarn add -D webpack-cli@https://pkg.pr.new/webpack-cli@4a88999
pnpm add -D webpack-cli@https://pkg.pr.new/webpack-cli@4a88999 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4893 +/- ##
==========================================
+ Coverage 94.95% 95.24% +0.28%
==========================================
Files 14 14
Lines 5950 5949 -1
Branches 915 916 +1
==========================================
+ Hits 5650 5666 +16
+ Misses 296 282 -14
+ Partials 4 1 -3
... and 2 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
|
No actionable comments were generated in the recent review.
|
Configuration files were loaded with
eval(\import("…")`). That was a workaround for TypeScript compilingimport()intorequire()` in CommonJS output, which can't load ES modules.The package now compiles with
module: "nodenext", and TypeScript keepsimport()as a real dynamic import in CommonJS output. The compiledlib/webpack-cli.jsalready does this for the other dynamic imports in the same file, for example the YAML/TOML parser import next to this code. So the configuration is now loaded with a plainawait import(...), and the compiled output has noevalleft.The behavior is the same: the configuration is imported from its
file://URL, and if that fails, theinterpret/rechoirfallback still runs.Checked locally:
import(…)with noeval;create-webpack-apppasses (154 suites), including the config-format tests (ESM, CommonJS, TypeScript, Babel, CoffeeScript, YAML, TOML and others).Generated by Claude Code
Summary by CodeRabbit