Skip to content

Comments

MAGMA-4673 Update sync-dynamic-imports reject unresolved imports with error and wrap require() with Promise.resolve#1030

Open
OliverWessels wants to merge 1 commit intomainfrom
MAGMA-4673-fix-sync-dynamic-imports-promise
Open

MAGMA-4673 Update sync-dynamic-imports reject unresolved imports with error and wrap require() with Promise.resolve#1030
OliverWessels wants to merge 1 commit intomainfrom
MAGMA-4673-fix-sync-dynamic-imports-promise

Conversation

@OliverWessels
Copy link
Contributor

Motivation

  • actual_require_paths creates a require(...) statement, which is not a promise. This is not correct because import(...) returns a promise. This adds a new config named sync_require_paths intended to replace that, which wraps with Promise.resolve.
  • Cleaning up activate_reject_on_unresolved_imports, which was added to feature-gate enable.

Changes

  • Removed activate_reject_on_unresolved_imports config option — unresolved dynamic imports now always generate
    rejecting promises
  • Added sync_require_paths config option — behaves the same as actual_require_paths (substring matching) but
    wraps matched imports in Promise.resolve(require(...)) instead of bare require(). Takes priority over
    actual_require_paths
  • Added syncDynamicImportRejectWithError feature flag — when enabled, unresolved imports reject with new Error(message) (with .skipSsr = true) instead of a plain string
  • Updated Rust (sync_dynamic_import.rs, js_transformer.rs, lib.rs), TypeScript (JSTransformer.ts), and feature
    flags (index.ts)

@changeset-bot
Copy link

changeset-bot bot commented Feb 17, 2026

🦋 Changeset detected

Latest commit: b96b9f2

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

This PR includes changesets to release 114 packages
Name Type
@atlaspack/transformer-js Minor
@atlaspack/rust Minor
@atlaspack/feature-flags Minor
@atlaspack/config-default Patch
atlaspack Patch
@atlaspack/transformer-compiled-css-in-js Patch
@atlaspack/transformer-tokens Patch
@atlaspack/bundler-default Patch
@atlaspack/cache Patch
@atlaspack/core Patch
@atlaspack/e2e-tests Patch
@atlaspack/fs Patch
@atlaspack/logger Patch
@atlaspack/source-map Patch
@atlaspack/utils Patch
@atlaspack/link Patch
@atlaspack/packaging-test-harness Patch
@atlaspack/optimizer-image Patch
@atlaspack/optimizer-inline-requires Patch
@atlaspack/packager-js Patch
@atlaspack/transformer-html Patch
@atlaspack/transformer-postcss Patch
@atlaspack/transformer-svg Patch
@atlaspack/node-resolver-core Patch
@atlaspack/build-cache Patch
@atlaspack/cli Patch
@atlaspack/graph Patch
@atlaspack/types-internal Patch
@atlaspack/inspector Patch
@atlaspack/packager-html Patch
@atlaspack/reporter-cli Patch
@atlaspack/reporter-compiled-css-in-js-migration-map Patch
@atlaspack/reporter-conditional-manifest Patch
@atlaspack/runtime-js Patch
@atlaspack/runtime-react-refresh Patch
@atlaspack/transformer-css Patch
@atlaspack/transformer-react-refresh-wrap Patch
@atlaspack/config-webextension Patch
@atlaspack/register Patch
@atlaspack/test-utils Patch
@atlaspack/query Patch
@atlaspack/bundle-stats Patch
@atlaspack/reporter-bundle-stats Patch
@atlaspack/transformer-image Patch
@atlaspack/inspector-frontend Patch
@atlaspack/package-manager Patch
@atlaspack/profiler Patch
@atlaspack/workers Patch
@atlaspack/watcher-watchman-js Patch
@atlaspack/optimizer-css Patch
@atlaspack/optimizer-cssnano Patch
@atlaspack/optimizer-swc Patch
@atlaspack/optimizer-terser Patch
@atlaspack/packager-css Patch
@atlaspack/transformer-babel Patch
@atlaspack/transformer-compiled-external Patch
@atlaspack/transformer-compiled Patch
@atlaspack/transformer-less Patch
@atlaspack/transformer-sass Patch
@atlaspack/transformer-typescript-tsc Patch
@atlaspack/transformer-typescript-types Patch
@atlaspack/optimizer-blob-url Patch
@atlaspack/optimizer-data-url Patch
@atlaspack/optimizer-svgo Patch
@atlaspack/packager-raw-url Patch
@atlaspack/packager-svg Patch
@atlaspack/packager-webextension Patch
@atlaspack/packager-xml Patch
@atlaspack/reporter-build-metrics Patch
@atlaspack/reporter-bundle-analyzer Patch
@atlaspack/reporter-dev-server Patch
@atlaspack/reporter-json Patch
@atlaspack/reporter-lsp Patch
@atlaspack/reporter-sourcemap-visualiser Patch
@atlaspack/reporter-tracer Patch
@atlaspack/resolver-glob Patch
@atlaspack/runtime-browser-hmr Patch
@atlaspack/runtime-service-worker Patch
@atlaspack/runtime-webextension Patch
@atlaspack/transformer-posthtml Patch
@atlaspack/transformer-webextension Patch
@atlaspack/transformer-webmanifest Patch
@atlaspack/validator-eslint Patch
@atlaspack/validator-typescript Patch
@atlaspack/resolver-default Patch
@atlaspack/resolver-tesseract Patch
@atlaspack/codeframe Patch
@atlaspack/plugin Patch
@atlaspack/types Patch
@atlaspack/reporter-bundle-buddy Patch
@atlaspack/transformer-xml Patch
@atlaspack/ts-utils Patch
@atlaspack/bundler-library Patch
@atlaspack/compressor-brotli Patch
@atlaspack/compressor-gzip Patch
@atlaspack/compressor-raw Patch
@atlaspack/namer-default Patch
@atlaspack/optimizer-htmlnano Patch
@atlaspack/packager-raw Patch
@atlaspack/packager-ts Patch
@atlaspack/packager-wasm Patch
@atlaspack/transformer-glsl Patch
@atlaspack/transformer-graphql Patch
@atlaspack/transformer-inline-string Patch
@atlaspack/transformer-inline Patch
@atlaspack/transformer-json Patch
@atlaspack/transformer-jsonld Patch
@atlaspack/transformer-mdx Patch
@atlaspack/transformer-pug Patch
@atlaspack/transformer-raw Patch
@atlaspack/transformer-svg-react Patch
@atlaspack/transformer-toml Patch
@atlaspack/transformer-worklet Patch
@atlaspack/transformer-yaml 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

@github-actions
Copy link
Contributor

Missing Changeset

No changeset found in PR.
Please add a changeset file (yarn changeset), or add a '[no-changeset]' tag with explanation to the PR description.

@github-actions
Copy link
Contributor

📊 Type Coverage Report

Coverage Comparison

Metric Baseline Current Change
Coverage Percentage 92.24% 92.24% ➡️ 0.00%
Correctly Typed 219,961 219,972 +11
Total Expressions 238,442 238,453 +11
Untyped Expressions 18,481 18,481 +0

Files with Most Type Issues (Top 15)

File Issues Affected Lines
packages/core/integration-tests/test/javascript.ts 1152 745
packages/core/integration-tests/test/cache.ts 885 626
packages/core/integration-tests/test/scope-hoisting.ts 622 489
packages/utils/node-resolver-core/test/resolver.ts 476 177
packages/core/integration-tests/test/html.ts 468 294
packages/core/integration-tests/test/sourcemaps.ts 364 182
packages/core/test-utils/src/utils.ts 330 205
packages/core/integration-tests/test/incremental-bundling.ts 298 206
packages/core/core/src/dumpGraphToGraphViz.ts 251 108
packages/core/integration-tests/test/transpilation.ts 230 139
packages/core/integration-tests/test/output-formats.ts 227 161
packages/transformers/webextension/src/WebExtensionTransformer.ts 210 80
packages/core/core/src/requests/BundleGraphRequestRust.ts 194 67
packages/core/integration-tests/test/css-modules.ts 191 107
packages/core/core/src/requests/TargetRequest.ts 190 133

This report was generated by the Type Coverage GitHub Action

@github-actions
Copy link
Contributor

📊 Benchmark Results

No significant performance changes detected.

📊 Benchmark Results

Overall Performance

Test Duration JS Memory Peak Native Memory Peak vs Baseline Status
Three.js Real Repository (JS) 15.44s 2.06GB 2.25GB N/A ⚪ New
Three.js Real Repository (V3) 21.45s 3.32GB 3.63GB N/A ⚪ New

🔍 Detailed Phase Analysis

Three.js Real Repository (JS)

Phase Duration (avg) Duration (p95) Memory Peak (avg) Memory Peak (p95)
resolving 7.28s 7.65s 1.45GB 1.77GB
transforming 7.26s 7.65s 1.45GB 1.78GB
bundling 7.08s 7.47s 1.45GB 1.78GB
bundled 6.71s 7.11s 1.55GB 1.87GB
packaging 4.58s 4.71s 1.66GB 1.98GB
optimizing 4.44s 4.56s 2.06GB 2.29GB

Three.js Real Repository (V3)

Phase Duration (avg) Duration (p95) Memory Peak (avg) Memory Peak (p95)
bundling 12.96s 19.63s 2.62GB 2.95GB
bundled 12.57s 19.30s 2.79GB 3.14GB
packaging 5.99s 6.43s 2.92GB 3.27GB
optimizing 5.83s 6.32s 3.32GB 3.63GB

💾 Unified Memory Analysis

Three.js Real Repository (JS) Memory Statistics

Memory Type Metric Min Mean Median P95 P99 Max Std Dev
JavaScript RSS 1.38GB 1.85GB 1.87GB 2.29GB 2.29GB 2.29GB 291.78MB
Heap Used 80.03MB 88.28MB 82.96MB 102.24MB 102.24MB 102.24MB 7.99MB
Heap Total 99.35MB 123.83MB 129.09MB 138.59MB 138.59MB 138.59MB 12.55MB
External 38.89MB 110.76MB 173.03MB 173.03MB 173.03MB 173.03MB 64.44MB
Native (Rust) Physical Memory 1.71GB 1.89GB 1.88GB 2.09GB 2.21GB 2.25GB 134.99MB
Virtual Memory 29.97GB 30.62GB 30.63GB 30.87GB 30.97GB 31.08GB 178.34MB

Sample Counts: JS: 14, Native: 242

Three.js Real Repository (V3) Memory Statistics

Memory Type Metric Min Mean Median P95 P99 Max Std Dev
JavaScript RSS 2.31GB 3.07GB 3.12GB 3.63GB 3.63GB 3.63GB 365.46MB
Heap Used 77.11MB 77.96MB 77.96MB 79.36MB 79.36MB 79.36MB 0.59MB
Heap Total 85.20MB 91.32MB 88.20MB 116.95MB 116.95MB 116.95MB 10.59MB
External 179.71MB 182.60MB 185.49MB 185.49MB 185.49MB 185.49MB 2.89MB
Native (Rust) Physical Memory 2.88GB 3.18GB 3.19GB 3.50GB 3.63GB 3.63GB 190.87MB
Virtual Memory 30.90GB 33.43GB 33.72GB 33.96GB 34.09GB 34.09GB 782.61MB

Sample Counts: JS: 14, Native: 250

🖥️ Environment

  • Node.js: v22.17.0
  • Platform: linux (x64)
  • CPU: AMD EPYC 7763 64-Core Processor
  • Total Memory: 15.62GB
  • Git SHA: b96b9f2
  • Branch: MAGMA-4673-fix-sync-dynamic-imports-promise
  • Timestamp: 2026-02-17T04:37:23.526Z

@OliverWessels OliverWessels changed the title MAGMA-4673 Update sync-dynamic-imports reject with error and wrap require() with Promise.resolve MAGMA-4673 Update sync-dynamic-imports reject unresolved imports with error and wrap require() with Promise.resolve Feb 17, 2026
@OliverWessels OliverWessels marked this pull request as ready for review February 17, 2026 05:00
@OliverWessels OliverWessels requested a review from a team as a code owner February 17, 2026 05:00
@OliverWessels OliverWessels self-assigned this Feb 17, 2026
Copy link
Contributor

@OscarCookeAbbott OscarCookeAbbott left a comment

Choose a reason for hiding this comment

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

Is this change safe to just push up like this, not feature gated for rollout etc?

fn create_rejecting_promise(&self, import_path: &Option<String>) -> Expr {
/// Legacy rejecting promise that rejects with a plain string.
/// Kept for backwards compatibility behind the `syncDynamicImportRejectWithError` feature flag.
fn create_rejecting_promise_old(&self, import_path: &Option<String>) -> Expr {
Copy link
Contributor

Choose a reason for hiding this comment

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

[nitpick] "old' is not particularly descriptive, string or 'warning' might be a better suffix for clarity here

@OliverWessels
Copy link
Contributor Author

Is this change safe to just push up like this, not feature gated for rollout etc?

Hey @OscarCookeAbbott I can't see exactly which code you're referring to. I believe this is feature gate safe because:

@OscarCookeAbbott
Copy link
Contributor

@OliverWessels Yes I just meant in general are these changes safe without rollout etc.

It seems ok to me then, but given a recent change here needed a rollback @marcins do you have a second to review too please?

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.

2 participants