Commit 7d79ed37de4 for nodejs

commit 7d79ed37de404bb137074eead038e32d679cc1a5
Author: Ali Hassan <24819103+thisalihassan@users.noreply.github.com>
Date:   Sun Sep 27 11:56:43 2026 +0500

    sea: add test and update docs for import() with code cache

    Signed-off-by: Ali Hassan <ali-hassan27@outlook.com>
    PR-URL: https://github.com/nodejs/node/pull/62678
    Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>

diff --git a/doc/api/single-executable-applications.md b/doc/api/single-executable-applications.md
index dd4478675fd..e5fa839a17f 100644
--- a/doc/api/single-executable-applications.md
+++ b/doc/api/single-executable-applications.md
@@ -352,8 +352,6 @@ executable application is launched, instead of compiling the `main` script from
 scratch, Node.js would use the code cache to speed up the compilation, then
 execute the script, which would improve the startup performance.

-**Note:** `import()` does not work when `useCodeCache` is `true`.
-
 ### Execution arguments

 The `execArgv` field can be used to specify Node.js-specific
@@ -587,8 +585,9 @@ injected main script with the following properties:

 <!-- TODO(joyeecheung): support and document module.registerHooks -->

-When using `"mainFormat": "module"`, `import()` can be used to dynamically
-load built-in modules. Attempting to use `import()` to load modules from
+`import()` can be used to dynamically load built-in modules in both
+CommonJS and ESM (`"mainFormat": "module"`) single executable applications.
+Attempting to use `import()` to load modules from
 the file system will throw an error.

 ### Using native addons in the injected main script
diff --git a/src/node_sea.cc b/src/node_sea.cc
index 0ce39ebe13a..065ec8285d9 100644
--- a/src/node_sea.cc
+++ b/src/node_sea.cc
@@ -752,12 +752,6 @@ std::optional<std::string> GenerateCodeCache(std::string_view main_path,
     Local<UnboundModuleScript> unbound = module->GetUnboundModuleScript();
     cache.reset(ScriptCompiler::CreateCodeCache(unbound));
   } else {
-    // TODO(RaisinTen): Using the V8 code cache prevents us from using
-    // `import()` in the SEA code. Support it. Refs:
-    // https://github.com/nodejs/node/pull/48191#discussion_r1213271430
-    // TODO(joyeecheung): this likely has been fixed by
-    // https://chromium-review.googlesource.com/c/v8/v8/+/5401780 - add a test
-    // and update docs.
     LocalVector<String> parameters(
         isolate,
         {
diff --git a/test/fixtures/sea/use-code-cache-dynamic-import/sea-config.json b/test/fixtures/sea/use-code-cache-dynamic-import/sea-config.json
new file mode 100644
index 00000000000..a2da0b9d143
--- /dev/null
+++ b/test/fixtures/sea/use-code-cache-dynamic-import/sea-config.json
@@ -0,0 +1,6 @@
+{
+  "main": "sea.js",
+  "output": "sea",
+  "useCodeCache": true,
+  "disableExperimentalSEAWarning": true
+}
diff --git a/test/fixtures/sea/use-code-cache-dynamic-import/sea.js b/test/fixtures/sea/use-code-cache-dynamic-import/sea.js
new file mode 100644
index 00000000000..90c8a1ac66d
--- /dev/null
+++ b/test/fixtures/sea/use-code-cache-dynamic-import/sea.js
@@ -0,0 +1,13 @@
+(async () => {
+  const assert = require('node:assert');
+
+  // Dynamic import of a built-in module should work even with code cache.
+  const { strictEqual } = await import('node:assert');
+  assert.strictEqual(strictEqual, assert.strictEqual);
+
+  // Dynamic import of another built-in module.
+  const { join } = await import('node:path');
+  assert.strictEqual(typeof join, 'function');
+
+  console.log('dynamic import with code cache works');
+})();
diff --git a/test/sea/test-single-executable-application-use-code-cache-dynamic-import.js b/test/sea/test-single-executable-application-use-code-cache-dynamic-import.js
new file mode 100644
index 00000000000..fe7cb2c3f61
--- /dev/null
+++ b/test/sea/test-single-executable-application-use-code-cache-dynamic-import.js
@@ -0,0 +1,34 @@
+'use strict';
+
+// This tests that import() works in a CJS single executable application
+// when useCodeCache is true.
+
+require('../common');
+
+const {
+  buildSEA,
+  skipIfBuildSEAIsNotSupported,
+} = require('../common/sea');
+
+skipIfBuildSEAIsNotSupported();
+
+const tmpdir = require('../common/tmpdir');
+const fixtures = require('../common/fixtures');
+const { spawnSyncAndAssert } = require('../common/child_process');
+
+tmpdir.refresh();
+
+const outputFile = buildSEA(fixtures.path('sea', 'use-code-cache-dynamic-import'));
+
+spawnSyncAndAssert(
+  outputFile,
+  [],
+  {
+    env: {
+      NODE_DEBUG_NATIVE: 'SEA',
+      ...process.env,
+    },
+  },
+  {
+    stdout: 'dynamic import with code cache works\n',
+  });