Skip to content

Full commonjs to es modules migration#1226

Merged
matux merged 10 commits intomasterfrom
matux/cjs-to-esm
Jul 13, 2025
Merged

Full commonjs to es modules migration#1226
matux merged 10 commits intomasterfrom
matux/cjs-to-esm

Conversation

@matux
Copy link
Copy Markdown
Contributor

@matux matux commented Jun 13, 2025

Description of the change

This PR fully migrates the codebase from CommonJS to ES modules, updating imports/exports and related configurations.

  • Converted require/module.exports to import/export in all source files
  • Added "type": "module" to package.json and updated build/test configs to .cjs extensions
  • Adjusted bundle snippets and examples to use ES module syntax

Related issues

SDK-492/migrate-source-code-to-es-modules

@matux matux requested a review from Copilot June 13, 2025 17:00
@matux matux self-assigned this Jun 13, 2025

This comment was marked as outdated.

@matux matux force-pushed the matux/cjs-to-esm branch from 35ee5cd to 69b5202 Compare June 13, 2025 17:01
@matux matux changed the title wip Migrates utility files from cjs to esm Jun 13, 2025
@matux matux force-pushed the matux/cjs-to-esm branch 2 times, most recently from 415d087 to 4d1b153 Compare June 13, 2025 18:35
@matux matux changed the title Migrates utility files from cjs to esm First batch of commonjs to es module migration Jun 13, 2025
@matux matux force-pushed the matux/cjs-to-esm branch 2 times, most recently from 8484bc9 to 9fed9ab Compare June 13, 2025 21:03
@matux matux changed the title First batch of commonjs to es module migration Full commonjs to es modules migration Jun 16, 2025
@matux matux requested a review from Copilot June 16, 2025 20:10
Copy link
Copy Markdown
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 PR fully migrates the codebase from CommonJS to ES modules, updating imports/exports and related configurations.

  • Converted require/module.exports to import/export in all source files
  • Added "type": "module" to package.json and updated build/test configs to .cjs extensions
  • Adjusted bundle snippets and examples to use ES module syntax

Reviewed Changes

Copilot reviewed 89 out of 89 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/browser/rollbar.js Replaced CommonJS requires with ES import and default export
src/browser/predicates.js Switched to named ES imports and exports
src/browser/logger.js Imported polyfill and utilities via ES modules, default export logger
src/browser/globalSetup.js Changed to named ES exports
src/browser/domUtility.js Converted to named ES exports
src/browser/detection.js Switched to default ES export
src/browser/defaults/scrubFields.js Changed default export to ES module
src/browser/core.js Updated all dependencies to ES imports, default export core
src/browser/bundles/rollbar.snippet.js Switched bundle snippet to ES imports
src/browser/bundles/rollbar.noconflict.js Converted to ES import and default export
src/browser/bundles/rollbar.js Updated bundle entry to ES modules
src/apiUtility.js Converted to named ES imports and exports
src/api.js Switched to ES imports and default export
package.json Added "type": "module"
karma.conf.cjs Updated require paths to .cjs files
examples/node-dist/index.cjs Updated source map reference to .cjs.map
bower.json Updated file list to reference .cjs configs
Gruntfile.cjs Updated webpack and karma config file references to .cjs
Comments suppressed due to low confidence (2)

src/browser/defaults/scrubFields.js:1

  • The default export here is an object containing a scrubFields property, but consumers (e.g., in core.js) import it as if it were the array itself. Consider exporting the array directly (export default [ ... ]) or use a named export and adjust the import to import { scrubFields }.
export default {

src/browser/logger.js:2

  • [nitpick] Verify that detection is used in this file. If it's no longer needed after the migration, remove this import to avoid unused dependencies.
import detection from './detection.js';

Comment thread src/browser/logger.js
@matux matux marked this pull request as ready for review June 16, 2025 20:15

/* eslint-disable no-console */
var logger = {
const logger = {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We should make a whole var -> const/let migration after.

Comment thread src/server/logger.js
Copy link
Copy Markdown
Member

@brianr brianr left a comment

Choose a reason for hiding this comment

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

Read each change. Looks good to me. Added one non-blocking question.

@matux matux force-pushed the matux/cjs-to-esm branch from 469095b to 9600e18 Compare July 10, 2025 19:09
@matux matux force-pushed the matux/cjs-to-esm branch from 9600e18 to 63a541c Compare July 10, 2025 19:11
Copy link
Copy Markdown
Contributor

@waltjones waltjones left a comment

Choose a reason for hiding this comment

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

✅ Looks good!

@matux matux merged commit 69e2464 into master Jul 13, 2025
4 checks passed
@matux matux deleted the matux/cjs-to-esm branch July 13, 2025 16:41
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.

4 participants