Skip to content

[frontend] Update to ESM (#14044)#14045

Draft
xfournet wants to merge 3 commits intomasterfrom
issue/14044-frontend-esm
Draft

[frontend] Update to ESM (#14044)#14045
xfournet wants to merge 3 commits intomasterfrom
issue/14044-frontend-esm

Conversation

@xfournet
Copy link
Member

Proposed changes

  • Update frontend to ESM

Related issues

Checklist

  • I consider the submitted work as finished
  • I tested the code for its functionality
  • I wrote test cases for the relevant uses case (coverage and e2e)
  • I added/update the relevant documentation (either on github or on notion)
  • Where necessary I refactored code to improve the overall quality

@xfournet xfournet requested a review from Copilot January 16, 2026 00:20
@xfournet xfournet self-assigned this Jan 16, 2026
@xfournet xfournet marked this pull request as draft January 16, 2026 00:20
@xfournet xfournet added technical improvement Technical refactor or improvement is needed filigran team use to identify PR from the Filigran team labels Jan 16, 2026
@xfournet xfournet force-pushed the issue/14044-frontend-esm branch 2 times, most recently from 45dd4ee to 324c1f9 Compare January 16, 2026 00:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request migrates the frontend codebase from CommonJS to ECMAScript Modules (ESM). The migration involves updating package.json to declare the module type, converting all require/module.exports statements to import/export syntax, and updating file references in configuration files.

Changes:

  • Added "type": "module" to package.json files to enable ESM
  • Converted all script files from CommonJS require/module.exports to ESM import/export syntax
  • Updated builder files (dev.js, prod.js, esbuild-relay.js) to use ESM imports
  • Updated ESLint plugin files to use ESM exports
  • Renamed vite.config.mts to vite.config.ts and updated references
  • Updated eslint.config.js reference from .mjs to .js extension

Reviewed changes

Copilot reviewed 16 out of 18 changed files in this pull request and generated 28 comments.

Show a summary per file
File Description
opencti-platform/opencti-front/package.json Added "type": "module" field and updated eslint.config reference from .mjs to .js
opencti-platform/opencti-front/vite.config.ts New Vite configuration file with ESM syntax (converted from .mts)
opencti-platform/opencti-front/tsconfig.node.json Updated reference from vite.config.mts to vite.config.ts
opencti-platform/opencti-front/eslint.config.js Updated vite.config reference from .mts to .ts
opencti-platform/opencti-front/script/verify-translation.js Converted from CommonJS to ESM with top-level await
opencti-platform/opencti-front/script/sort-translation-files.js Converted from CommonJS to ESM with async/await pattern
opencti-platform/opencti-front/script/extract-label-keyword.js Converted from CommonJS to ESM with top-level await
opencti-platform/opencti-front/script/extract-i18n-keyword.js Converted from CommonJS to ESM with top-level await
opencti-platform/opencti-front/script/auto-translate.js Converted from CommonJS to ESM with top-level await
opencti-platform/opencti-front/builder/prod/prod.js Converted builder script to use ESM imports
opencti-platform/opencti-front/builder/dev/dev.js Converted dev server to use ESM imports
opencti-platform/opencti-front/builder/plugin/esbuild-relay.js Converted plugin imports to ESM (partial conversion)
opencti-platform/opencti-front/packages/eslint-plugin-custom-rules/package.json Added "type": "module" to enable ESM
opencti-platform/opencti-front/packages/eslint-plugin-custom-rules/lib/index.js Converted to ESM export syntax
opencti-platform/opencti-front/packages/eslint-plugin-custom-rules/lib/rules/classes-rule.js Converted to ESM export default syntax
opencti-platform/opencti-front/packages/eslint-plugin-custom-rules/tests/lib/rules/classes-rule.test.js Converted to ESM import syntax
.github/copilot-instructions.md Updated documentation references from .mjs to .js
Comments suppressed due to low confidence (1)

opencti-platform/opencti-front/script/extract-i18n-keyword.js:37

  • Avoid automated semicolon insertion (90% of all statements in the enclosing function have an explicit semicolon).
            })

sortedJSON[key] = json[key];
});
return sortedJSON;
}
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

Missing semicolon at the end of the statement. For consistency with the rest of the codebase, add a semicolon after the closing brace.

Copilot uses AI. Check for mistakes.
@xfournet xfournet force-pushed the issue/14044-frontend-esm branch 3 times, most recently from 2c2c685 to ab3f2b5 Compare January 16, 2026 01:00
@xfournet xfournet requested a review from Copilot January 16, 2026 01:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 16 out of 18 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (3)

opencti-platform/opencti-front/script/sort-translation-files.js:22

  • The code references fs.writeFileSync but fs is not imported. The file imports readFile and readdir from 'node:fs/promises' but needs to also import writeFile to use the async API consistently. Change fs.writeFileSync(...) to await writeFile(...) and update the import statement to include writeFile.
    fs.writeFileSync(filePath, JSON.stringify(sortedJSON, null, 2));

opencti-platform/opencti-front/eslint.config.js:66

  • The custom-rules plugin export structure appears incorrect. ESLint plugins should export an object with a rules property, but here you're wrapping the imported customRules (which should already be the rules object) in another object with a rules property. Based on the updated lib/index.js which exports a plain object mapping rule names to rule implementations, this line should be 'custom-rules': customRules instead.
    opencti-platform/opencti-front/script/extract-i18n-keyword.js:37
  • Avoid automated semicolon insertion (90% of all statements in the enclosing function have an explicit semicolon).
            })

@xfournet xfournet force-pushed the issue/14044-frontend-esm branch from 73624fb to f865fe0 Compare February 26, 2026 20:41
xfournet and others added 2 commits February 26, 2026 21:55
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@xfournet xfournet marked this pull request as ready for review February 26, 2026 20:58
@xfournet xfournet marked this pull request as draft February 26, 2026 21:55
@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 32.36%. Comparing base (39a8539) to head (2fb397a).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #14045   +/-   ##
=======================================
  Coverage   32.36%   32.36%           
=======================================
  Files        3096     3096           
  Lines      210891   210891           
  Branches    38200    38200           
=======================================
  Hits        68263    68263           
  Misses     142628   142628           
Flag Coverage Δ
opencti-client-python 45.50% <ø> (ø)
opencti-front 2.83% <ø> (ø)
opencti-graphql 67.73% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

filigran team use to identify PR from the Filigran team technical improvement Technical refactor or improvement is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update frontend to ESM

2 participants