Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 31, 2025

CLI-generated Atomic projects fail to build or start on Node < 20.19.0 due to ES module handling differences when Stencil internally converts ES imports to CommonJS require() calls for the @coveo/create-atomic-rollup-plugin package.

Changes

Detection and patching logic (createAtomicProject.ts):

  • Added shouldAddExperimentalDetectModuleFlag() to detect Node < 20.19.0 using semver
  • Added patchPackageJsonScripts() to inject --experimental-detect-module flag into generated project's build and start scripts
  • Modified createAtomicApp() to apply patch after successful project creation

Pattern matching:

  • Only patches scripts starting with stencil command (regex: ^\s*stencil\b)
  • Replaces stencilnode --experimental-detect-module ./node_modules/.bin/stencil

Error handling:

  • Logs warning with project path and manual fix instructions if patching fails
  • Does not fail project creation on patch errors

Example

Before (generated project fails on Node 20.18.0):

{
  "scripts": {
    "start": "stencil build --dev --watch --serve",
    "build": "stencil build && node deployment.esbuild.mjs"
  }
}

After (auto-patched on Node < 20.19.0):

{
  "scripts": {
    "start": "node --experimental-detect-module ./node_modules/.bin/stencil build --dev --watch --serve",
    "build": "node --experimental-detect-module ./node_modules/.bin/stencil build && node deployment.esbuild.mjs"
  }
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/1108766/chrome-linux.zip
    • Triggering command: node install.js (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>build/start commands fail in CLI-generated Atomic projects when using Node < 20.19.0</issue_title>
<issue_description>## Describe the bug

When executing the build or start command in an Atomic project generated with the CLI, the command fails with an ES module error.

To Reproduce

Steps to reproduce the behavior:

  1. nvm install 20.18
  2. nvm use 20.18
  3. npm i -g @coveo/cli@latest
  4. coveo auth:login -o=orgid
  5. coveo ui:create:atomic --version=latest my-project
  6. In the generated project, edit /src/index.ts to remove HTMLAtomicSearchInterfaceElement (this is another, unrelated issue).
  7. npm run build (should fail with an ES module error).
  8. npm run start (should fail with an ES module error).

Note: If you run the reproduction steps by using 20.19 instead of 20.18 at steps 1 and 2, steps 7 and 8 will not fail.

Expected behavior

The npm run build and npm run start commands should succeed without any errors or warnings on node 20.x, not just node >= 20.19

Desktop (please complete the following information):

  • OS: macOS
    • OS version: Sequoia 15.16.1
  • Browser: N/A
    • Browser version: N/A
  • Version of the CLI: 3.2.13
  • Local Node version: 20.18
  • Local NPM version: 10.8.2

Additional context

Cause

The apparent root cause is that the @coveo/create-atomic-rollup-plugin package is distributed as a pure ES module (with "type": "module" in its package.json), but the Stencil configuration is trying to import it using the old CommonJS require import syntax.

The stencil.config.ts file uses the correct “import” syntax, but at build time, the Stencil compiler internally converts the ES module imports to require() calls.

Node.js versions < 20.19 have stricter ES module handling, which causes the build to fail when using node 20.9.0 and 20.17.0, but not when using 20.19.0.

Workarounds

Option 1: Use node >= 20.19 (however you must use node 20, as the CLI doesn’t currently support node > 20).

Option 2: Replace the build and start scripts in the CLI-generated project’s package.json as follows:

{
  // ...
  "scripts": {
    "start": "node --experimental-detect-module ./node_modules/.bin/stencil build --dev --watch --serve",
    "build": "node --experimental-detect-module ./node_modules/.bin/stencil build && node deployment.esbuild.mjs",
    // ...
  }
  // ...
}

Potential Fix

We’d have to make sure that when we generate an Atomic project with the CLI, if the node version is below 20.19, we pass the --experimental-dectect-module flag when running the Stencil buildcommand in the project’s package.json build and start commands.

Reference

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


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits October 31, 2025 14:16
Co-authored-by: fbeaudoincoveo <23503066+fbeaudoincoveo@users.noreply.github.com>
…sages

Co-authored-by: fbeaudoincoveo <23503066+fbeaudoincoveo@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix build and start command errors in Atomic projects Fix build/start commands for Atomic projects on Node < 20.19.0 Oct 31, 2025
Copilot AI requested a review from fbeaudoincoveo October 31, 2025 14:24
@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2025

Pull Request Report

PR Title

✅ Title follows the conventional commit spec.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2025

Pull Request Title is not semantic:

✏️ input: [WIP] Fix build and start command errors in Atomic projects
❌ subject may not be empty [subject-empty]
❌ type may not be empty [type-empty]

❌ found 2 problems, 0 warnings
ℹ️ Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint

@fbeaudoincoveo fbeaudoincoveo changed the title Fix build/start commands for Atomic projects on Node < 20.19.0 fix(cli): build/start commands for Atomic projects on Node < 20.19.0 Dec 11, 2025
@github-actions
Copy link
Contributor

Pull Request Title is not semantic:

✏️ input: Fix build/start commands for Atomic projects on Node < 20.19.0
❌ subject may not be empty [subject-empty]
❌ type may not be empty [type-empty]

❌ found 2 problems, 0 warnings
ℹ️ Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint

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.

build/start commands fail in CLI-generated Atomic projects when using Node < 20.19.0

2 participants