Skip to content

chore: esm only#24

Open
dopry wants to merge 1 commit into
nextfrom
chore/esm
Open

chore: esm only#24
dopry wants to merge 1 commit into
nextfrom
chore/esm

Conversation

@dopry
Copy link
Copy Markdown
Owner

@dopry dopry commented Sep 20, 2025

!BREAKING CHANGE:

@dopry dopry requested a review from Copilot September 20, 2025 03:45
Copy link
Copy Markdown

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 transitions the project from a dual CommonJS/ESM build setup to ESM-only, representing a breaking change that simplifies the build configuration and modernizes the package structure.

  • Removes dual build system and related TypeScript configurations
  • Updates package.json to specify "type": "module" and consolidates entry points
  • Replaces CommonJS module detection pattern with ESM equivalent using import.meta.url

Reviewed Changes

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

Show a summary per file
File Description
tsconfig.test.json Removed test-specific TypeScript configuration
tsconfig.mjs.json Removed ESM-specific TypeScript configuration
tsconfig.cjs.json Removed CommonJS-specific TypeScript configuration
src/index.ts Updated module detection from require.main to import.meta.url pattern
package.json Set module type to ESM, updated build scripts, and replaced ts-node with tsx
fixup.sh Removed build script that created dual package.json files
.eslintrc Minor formatting cleanup and removed mocha environment
.cfignore Removed Cloud Foundry ignore file
.babelrc Removed Babel configuration

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/index.ts
Comment on lines +82 to +89
if (import.meta.url.startsWith("file:")) {
const modulePath = url.fileURLToPath(import.meta.url);
// Compare the module's path to the path of the main module being executed
// This approach might need adjustments for symbolic links or specific execution contexts
if (process.argv[1] === modulePath) {
// This code block will execute only when the ESM module is run directly
main();
}
Copy link

Copilot AI Sep 20, 2025

Choose a reason for hiding this comment

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

The condition import.meta.url.startsWith("file:") is unnecessary since import.meta.url will always be a file: URL in Node.js when running local files. The logic should be simplified to just check if the resolved module path matches process.argv[1].

Suggested change
if (import.meta.url.startsWith("file:")) {
const modulePath = url.fileURLToPath(import.meta.url);
// Compare the module's path to the path of the main module being executed
// This approach might need adjustments for symbolic links or specific execution contexts
if (process.argv[1] === modulePath) {
// This code block will execute only when the ESM module is run directly
main();
}
const modulePath = url.fileURLToPath(import.meta.url);
// Compare the module's path to the path of the main module being executed
// This approach might need adjustments for symbolic links or specific execution contexts
if (process.argv[1] === modulePath) {
// This code block will execute only when the ESM module is run directly
main();

Copilot uses AI. Check for mistakes.
!BREAKING CHANGE:
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