Skip to content

Feat/tsup#681

Closed
carlbrugger wants to merge 16 commits intomainfrom
feat/tsup
Closed

Feat/tsup#681
carlbrugger wants to merge 16 commits intomainfrom
feat/tsup

Conversation

@carlbrugger
Copy link
Contributor

@carlbrugger carlbrugger commented Oct 23, 2024

Please explain how to summarize this PR for the Changelog:

This PR switches rollup and parcel out for tsup. Also integrates @arethetypeswrong/cli and reconfigures the exports in package.json so that they are all 🟢. No more:

  • 👺 Masquerading as ESM
  • 💀 Resolution failed
  • 🐛 Used fallback condition
  • ⚠️ Entrypoint is ESM-only
  • ❌ No types.

Tell code reviewer how and what to test:

@carlbrugger carlbrugger marked this pull request as ready for review October 23, 2024 07:18
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 23, 2024

Walkthrough

This pull request introduces significant changes to the Flatfile plugins and utilities, primarily focusing on updating the bundler configurations from Rollup to tsup. It includes the renaming of the package from @flatfile/rollup-config to @flatfile/bundler-config-rollup and the addition of new configuration files for tsup across various plugins. The changes also involve updates to import statements and the structure of configuration exports, ensuring better organization and management of plugin settings.

Changes

File Path Change Summary
bundlers/rollup-config/CHANGELOG.md Updated package name and documented two releases with changes to bundler configurations.
convert/currency/rollup.config.mjs Deleted Rollup configuration file; default export removed.
convert/currency/tsup.config.mjs Added new tsup configuration file with default export.
convert/translate/rollup.config.mjs Deleted Rollup configuration file; default export removed.
convert/translate/tsup.config.mjs Added new tsup configuration file with default export.
convert/what3words/rollup.config.mjs Deleted Rollup configuration file; default export removed.
convert/what3words/tsup.config.mjs Added new tsup configuration file with default export.
enrich/geocode/rollup.config.mjs Deleted Rollup configuration file; default export removed.
enrich/geocode/tsup.config.mjs Added new tsup configuration file with default export.
enrich/gpx/rollup.config.mjs Deleted Rollup configuration file; default export removed.
enrich/gpx/tsup.config.mjs Added new tsup configuration file with default export.
enrich/sentiment/rollup.config.mjs Deleted Rollup configuration file; default export removed.
enrich/sentiment/tsup.config.mjs Added new tsup configuration file with default export.
enrich/summarize/rollup.config.mjs Deleted Rollup configuration file; default export removed.
enrich/summarize/tsup.config.mjs Added new tsup configuration file with default export.
export/pivot-table/rollup.config.mjs Deleted Rollup configuration file; default export removed.
export/pivot-table/tsup.config.mjs Added new tsup configuration file with default export.
extract/html-table/rollup.config.mjs Deleted Rollup configuration file; default export removed.
extract/html-table/tsup.config.mjs Added new tsup configuration file with default export.
extract/markdown/rollup.config.mjs Deleted Rollup configuration file; default export removed.
extract/markdown/tsup.config.mjs Added new tsup configuration file with default export.
import/faker/rollup.config.mjs Deleted Rollup configuration file; default export removed.
import/faker/tsup.config.mjs Added new tsup configuration file with default export.
import/llm-records/rollup.config.mjs Deleted Rollup configuration file; default export removed.
import/llm-records/tsup.config.mjs Added new tsup configuration file with default export.
import/rss/rollup.config.mjs Deleted Rollup configuration file; default export removed.
import/rss/tsup.config.mjs Added new tsup configuration file with default export.
plugins/autocast/rollup.config.mjs Deleted Rollup configuration file; default export removed.
plugins/autocast/tsup.config.mjs Added new tsup configuration file with default export.
plugins/automap/tsup.config.mjs Added new tsup configuration file with default export.
plugins/constraints/rollup.config.mjs Deleted Rollup configuration file; default export removed.
plugins/constraints/tsup.config.mjs Added new tsup configuration file with default export.
plugins/dedupe/rollup.config.mjs Deleted Rollup configuration file; default export removed.
plugins/dedupe/tsup.config.mjs Added new tsup configuration file with default export.
plugins/delimiter-extractor/src/parser.ts Updated import statement for DelimiterOptions.
plugins/delimiter-extractor/tsup.config.mjs Added new tsup configuration file with includeBrowser set to false.
plugins/dxp-configure/rollup.config.mjs Deleted Rollup configuration file; default export removed.
plugins/dxp-configure/tsup.config.mjs Added new tsup configuration file with default export.
plugins/export-workbook/rollup.config.mjs Deleted Rollup configuration file; default export removed.
plugins/export-workbook/tsup.config.mjs Added new tsup configuration file with includeBrowser set to false.
plugins/foreign-db-extractor/rollup.config.mjs Deleted Rollup configuration file; default export removed.
plugins/foreign-db-extractor/tsup.config.mjs Added new tsup configuration file with default export.
plugins/graphql-schema/rollup.config.mjs Deleted Rollup configuration file; default export removed.
plugins/graphql-schema/tsup.config.mjs Added new tsup configuration file with default export.
plugins/job-handler/rollup.config.mjs Deleted Rollup configuration file; default export removed.
plugins/job-handler/tsup.config.mjs Added new tsup configuration file with default export.
plugins/json-extractor/rollup.config.mjs Deleted Rollup configuration file; default export removed.
plugins/json-extractor/tsup.config.mjs Added new tsup configuration file with default export.
plugins/json-schema/tsup.config.mjs Added new tsup configuration file with default export.
plugins/merge-connection/README.md Updated import statement for mergePlugin in README.
plugins/merge-connection/src/index.ts Modified export structure for mergePlugin.
plugins/merge-connection/src/merge.plugin.ts Changed mergePlugin from default to named export.
plugins/record-hook/rollup.config.mjs Updated import statement and added new properties to configuration.
bundlers/rollup-config/index.js Updated buildConfig function with new parameters and conditional logic.
bundlers/tsup-config/index.js Introduced new configuration setup for the tsup bundler.

Possibly related PRs

  • chore: update versions #572: This PR updates the versions of several Flatfile plugins, including changes to the @flatfile/util-extractor, which is relevant to the main PR's focus on bundler configuration and plugin management.
  • chore: update versions #580: Similar to chore: update versions #572, this PR also updates the versions of Flatfile plugins, including the @flatfile/util-extractor, which aligns with the main PR's changes regarding plugin dependencies.
  • feat: upgrade @flatfile/api #606: This PR addresses updates to various Flatfile plugins, which may relate to the main PR's changes in plugin configurations and dependencies.
  • chore: deps update #615: This PR updates dependencies across multiple Flatfile plugins, which could be relevant to the main PR's focus on bundler configurations and plugin management.
  • fix:non-string values #616: This PR fixes an issue with XLSX file extraction, which may relate to the main PR's changes in handling plugins and configurations.
  • validator: text summarizer #629: This PR introduces a new summarization plugin, which may connect to the main PR's updates in plugin configurations and management.
  • extractor: Markdown Extractor #643: This PR introduces a Markdown extractor plugin, which may relate to the main PR's focus on bundler configurations and plugin management.
  • feat: add skipEmptyLines option #644: This PR adds a skipEmptyLines option to plugins, which directly relates to the main PR's focus on improving plugin functionality and configurations.
  • chore: update documentation #646: This PR updates documentation for plugins, which is relevant to the main PR's changes in plugin configurations and management.
  • Changeset for PR #654 #655: This PR introduces patch updates to multiple Flatfile plugins, which may relate to the main PR's focus on plugin management.
  • chore: update changeset #667: This PR documents the initial launch of several Flatfile plugins, which may connect to the main PR's updates in plugin configurations.
  • feat: remove remeda & add disableFileNameUpdate option #672: This PR introduces a new option in the @flatfile/plugin-automap, which may relate to the main PR's focus on plugin configurations.
  • fix: async issue #674: This PR addresses an async issue in plugins, which may connect to the main PR's updates in plugin management.
  • feat: fix some Readmes #677: This PR focuses on fixing README files for plugins, which may relate to the main PR's updates in documentation and plugin configurations.

Suggested reviewers

  • bangarang

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ff63707 and f93e614.

⛔ Files ignored due to path filters (4)
  • bundlers/rollup-config/package.json is excluded by !**/*.json
  • enrich/geocode/package.json is excluded by !**/*.json
  • package-lock.json is excluded by !**/package-lock.json, !**/*.json
  • package.json is excluded by !**/*.json
📒 Files selected for processing (2)
  • .gitignore (0 hunks)
  • bundlers/tsup-config/index.js (1 hunks)
💤 Files with no reviewable changes (1)
  • .gitignore
🚧 Files skipped from review as they are similar to previous changes (1)
  • bundlers/tsup-config/index.js

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Outside diff range and nitpick comments (4)
bundlers/rollup-config/CHANGELOG.md (2)

1-1: Add a deprecation notice at the top of the changelog.

Since this PR aims to replace rollup with tsup, we should add a clear deprecation notice to guide users:

 # @flatfile/bundler-config-rollup
+
+> ⚠️ **DEPRECATED**: This package is being replaced by tsup-based bundling configuration. 
+> Please migrate to the new tsup configuration package (add package name here).

Based on the gathered information, I can now provide a final response:

Package is being replaced by tsup-based bundling configuration

The evidence clearly shows that:

  1. A widespread migration from rollup to tsup is in progress, with numerous tsup configurations (tsup.config.mjs) present across the codebase
  2. Recent commits indicate the transition: "tsup vs rollup", "just tsup", "new plugins -> tsup"
  3. The package is marked as "private: true" in package.json
  4. Several packages still have this as a devDependency in version 0.1.1

Action items for the changelog:

  • Add a deprecation notice stating this package is being replaced by @flatfile/bundler-config-tsup
  • Document that versions 0.1.0 and 0.1.1 were transitional releases
  • Add migration instructions for dependent packages to switch to the new tsup-based configuration
🔗 Analysis chain

Line range hint 1-13: Please clarify the lifecycle status of this package.

Given that this PR's objective is to replace rollup with tsup, we should address:

  1. Whether these recent changes (0.1.0, 0.1.1) are transitional
  2. The timeline for deprecation
  3. Migration steps for users

This will help users understand the package's status and plan their migration accordingly.

Let's check if there are any active dependents of this package:


Let me gather more information about the dependencies and any migration plans.


Let me check for any tsup-related changes or migration documentation in the repository.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for dependencies on the old and new package names
rg -l "@flatfile/(rollup-config|bundler-config-rollup)"

Length of output: 302


Script:

#!/bin/bash
# Check package.json files for dependency details
echo "=== Checking package.json files ==="
for file in validate/date/package.json validate/boolean/package.json extract/markdown/package.json convert/what3words/package.json; do
  echo "=== $file ==="
  cat "$file" | grep -A 5 -B 5 "@flatfile/.*rollup"
done

# Check for any migration documentation
echo -e "\n=== Checking for migration docs ==="
rg -l "migration|deprecat|tsup" -g "*.md"

# Check the rollup-config package.json for deprecation notices
echo -e "\n=== Checking rollup-config package.json ==="
cat bundlers/rollup-config/package.json

Length of output: 2863


Script:

#!/bin/bash
# Check for tsup configuration and related changes
echo "=== Checking for tsup configuration ==="
rg -l "tsup.config|tsup"

# Check recent commits for migration context
echo -e "\n=== Checking recent commits ==="
git log --grep="tsup\|rollup\|bundler" --pretty=format:"%h %s" -n 5

# Check for any deprecation notices in changelogs
echo -e "\n=== Checking changelogs for deprecation notices ==="
rg "deprecat|tsup|rollup" -g "CHANGELOG.md"

Length of output: 5053

bundlers/tsup-config/index.mjs (1)

7-9: Consider using a proper logger instead of console.log

While logging the minification status is helpful for debugging, consider using a proper logger that can be controlled via log levels and disabled in production.

-if (!PROD) {
-  console.log('Not in production mode - skipping minification')
-}
+import debug from 'debug'
+const log = debug('flatfile:bundler:tsup')
+
+if (!PROD) {
+  log('Not in production mode - skipping minification')
+}
bundlers/rollup-config/index.mjs (1)

The Rollup configuration can be safely removed

Based on the evidence:

  1. All packages that previously depended on @flatfile/bundler-config-rollup (validate/date, validate/boolean, extract/markdown, convert/what3words) have already migrated to tsup, as shown by their package.json scripts using "tsup" instead of "rollup"
  2. There is widespread adoption of tsup across the codebase with 51 tsup.config.mjs files found
  3. No active rollup.config files were found that use this configuration

The Rollup configuration is no longer needed and should be removed as part of this PR since the migration to tsup is complete.

🔗 Analysis chain

Line range hint 1-108: Verify if this Rollup configuration is still needed.

Given that the PR objective is to migrate from Rollup to tsup, we should verify if this configuration file is:

  1. Still being used during the transition
  2. Kept as a reference for tsup configuration
  3. Should be removed as part of this PR

Let's check its usage:


Let me gather more information to verify if this configuration is actively being used or if it's safe to remove.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if this config is referenced in package.json scripts
fd package.json --exec cat {} | jq 'select(.scripts != null) | .scripts | to_entries[] | select(.value | contains("rollup"))'

# Look for other files importing this config
rg -g '!dist' -g '!node_modules' "@flatfile/(rollup-config|bundler-config-rollup)"

Length of output: 1167


Script:

#!/bin/bash
# Check for rollup.config files that might use this configuration
fd rollup.config

# Check package.json files in the packages that depend on rollup-config
echo "=== validate/date/package.json ==="
cat validate/date/package.json | jq '.scripts'

echo "=== validate/boolean/package.json ==="
cat validate/boolean/package.json | jq '.scripts'

echo "=== extract/markdown/package.json ==="
cat extract/markdown/package.json | jq '.scripts'

echo "=== convert/what3words/package.json ==="
cat convert/what3words/package.json | jq '.scripts'

# Check if there are any recent migrations to tsup
fd tsup.config

Length of output: 4034

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 77df987 and 8b6dd51.

⛔ Files ignored due to path filters (61)
  • bundlers/rollup-config/package.json is excluded by !**/*.json
  • bundlers/tsup-config/package.json is excluded by !**/*.json
  • convert/currency/package.json is excluded by !**/*.json
  • convert/translate/package.json is excluded by !**/*.json
  • convert/what3words/package.json is excluded by !**/*.json
  • enrich/geocode/package.json is excluded by !**/*.json
  • enrich/gpx/package.json is excluded by !**/*.json
  • enrich/sentiment/package.json is excluded by !**/*.json
  • enrich/summarize/package.json is excluded by !**/*.json
  • export/pivot-table/package.json is excluded by !**/*.json
  • extract/html-table/package.json is excluded by !**/*.json
  • extract/markdown/package.json is excluded by !**/*.json
  • import/faker/package.json is excluded by !**/*.json
  • import/llm-records/package.json is excluded by !**/*.json
  • import/rss/package.json is excluded by !**/*.json
  • package-lock.json is excluded by !**/package-lock.json, !**/*.json
  • package.json is excluded by !**/*.json
  • plugins/autocast/package.json is excluded by !**/*.json
  • plugins/automap/package.json is excluded by !**/*.json
  • plugins/constraints/package.json is excluded by !**/*.json
  • plugins/dedupe/package.json is excluded by !**/*.json
  • plugins/delimiter-extractor/package.json is excluded by !**/*.json
  • plugins/dxp-configure/package.json is excluded by !**/*.json
  • plugins/export-workbook/package.json is excluded by !**/*.json
  • plugins/foreign-db-extractor/package.json is excluded by !**/*.json
  • plugins/graphql-schema/package.json is excluded by !**/*.json
  • plugins/job-handler/package.json is excluded by !**/*.json
  • plugins/json-extractor/package.json is excluded by !**/*.json
  • plugins/json-schema/package.json is excluded by !**/*.json
  • plugins/merge-connection/package.json is excluded by !**/*.json
  • plugins/openapi-schema/package.json is excluded by !**/*.json
  • plugins/pdf-extractor/package.json is excluded by !**/*.json
  • plugins/psv-extractor/package.json is excluded by !**/*.json
  • plugins/record-hook/package.json is excluded by !**/*.json
  • plugins/rollout/package.json is excluded by !**/*.json
  • plugins/space-configure/package.json is excluded by !**/*.json
  • plugins/sql-ddl-converter/package.json is excluded by !**/*.json
  • plugins/tsv-extractor/package.json is excluded by !**/*.json
  • plugins/view-mapped/package.json is excluded by !**/*.json
  • plugins/webhook-egress/package.json is excluded by !**/*.json
  • plugins/webhook-event-forwarder/package.json is excluded by !**/*.json
  • plugins/xlsx-extractor/package.json is excluded by !**/*.json
  • plugins/xml-extractor/package.json is excluded by !**/*.json
  • plugins/yaml-schema/package.json is excluded by !**/*.json
  • plugins/zip-extractor/package.json is excluded by !**/*.json
  • support/common-utils/package.json is excluded by !**/*.json
  • tsconfig.json is excluded by !**/*.json
  • turbo.json is excluded by !**/*.json
  • utils/common/package.json is excluded by !**/*.json
  • utils/extractor/package.json is excluded by !**/*.json
  • utils/fetch-schema/package.json is excluded by !**/*.json
  • utils/file-buffer/package.json is excluded by !**/*.json
  • utils/response-rejection/package.json is excluded by !**/*.json
  • utils/testing/package.json is excluded by !**/*.json
  • validate/boolean/package.json is excluded by !**/*.json
  • validate/date/package.json is excluded by !**/*.json
  • validate/email/package.json is excluded by !**/*.json
  • validate/isbn/package.json is excluded by !**/*.json
  • validate/number/package.json is excluded by !**/*.json
  • validate/phone/package.json is excluded by !**/*.json
  • validate/string/package.json is excluded by !**/*.json
📒 Files selected for processing (100)
  • bundlers/rollup-config/CHANGELOG.md (1 hunks)
  • bundlers/rollup-config/index.mjs (3 hunks)
  • bundlers/tsup-config/index.mjs (1 hunks)
  • convert/currency/rollup.config.mjs (0 hunks)
  • convert/currency/tsup.config.mjs (1 hunks)
  • convert/translate/rollup.config.mjs (0 hunks)
  • convert/translate/tsup.config.mjs (1 hunks)
  • convert/what3words/rollup.config.mjs (0 hunks)
  • convert/what3words/tsup.config.mjs (1 hunks)
  • enrich/geocode/rollup.config.mjs (0 hunks)
  • enrich/geocode/tsup.config.mjs (1 hunks)
  • enrich/gpx/rollup.config.mjs (0 hunks)
  • enrich/gpx/tsup.config.mjs (1 hunks)
  • enrich/sentiment/rollup.config.mjs (0 hunks)
  • enrich/sentiment/tsup.config.mjs (1 hunks)
  • enrich/summarize/rollup.config.mjs (0 hunks)
  • enrich/summarize/tsup.config.mjs (1 hunks)
  • export/pivot-table/rollup.config.mjs (0 hunks)
  • export/pivot-table/tsup.config.mjs (1 hunks)
  • extract/html-table/rollup.config.mjs (0 hunks)
  • extract/html-table/tsup.config.mjs (1 hunks)
  • extract/markdown/rollup.config.mjs (0 hunks)
  • extract/markdown/tsup.config.mjs (1 hunks)
  • import/faker/rollup.config.mjs (0 hunks)
  • import/faker/tsup.config.mjs (1 hunks)
  • import/llm-records/rollup.config.mjs (0 hunks)
  • import/llm-records/tsup.config.mjs (1 hunks)
  • import/rss/rollup.config.mjs (0 hunks)
  • import/rss/tsup.config.mjs (1 hunks)
  • plugins/autocast/rollup.config.mjs (0 hunks)
  • plugins/autocast/tsup.config.mjs (1 hunks)
  • plugins/automap/tsup.config.mjs (1 hunks)
  • plugins/constraints/rollup.config.mjs (0 hunks)
  • plugins/constraints/tsup.config.mjs (1 hunks)
  • plugins/dedupe/rollup.config.mjs (0 hunks)
  • plugins/dedupe/tsup.config.mjs (1 hunks)
  • plugins/delimiter-extractor/src/parser.ts (2 hunks)
  • plugins/delimiter-extractor/tsup.config.mjs (1 hunks)
  • plugins/dxp-configure/rollup.config.mjs (0 hunks)
  • plugins/dxp-configure/tsup.config.mjs (1 hunks)
  • plugins/export-workbook/rollup.config.mjs (0 hunks)
  • plugins/export-workbook/tsup.config.mjs (1 hunks)
  • plugins/foreign-db-extractor/rollup.config.mjs (0 hunks)
  • plugins/foreign-db-extractor/tsup.config.mjs (1 hunks)
  • plugins/graphql-schema/rollup.config.mjs (0 hunks)
  • plugins/graphql-schema/tsup.config.mjs (1 hunks)
  • plugins/job-handler/rollup.config.mjs (0 hunks)
  • plugins/job-handler/tsup.config.mjs (1 hunks)
  • plugins/json-extractor/CHANGELOG.md (1 hunks)
  • plugins/json-extractor/rollup.config.mjs (0 hunks)
  • plugins/json-extractor/tsup.config.mjs (1 hunks)
  • plugins/json-schema/tsup.config.mjs (1 hunks)
  • plugins/merge-connection/tsup.config.mjs (1 hunks)
  • plugins/openapi-schema/rollup.config.mjs (0 hunks)
  • plugins/openapi-schema/tsup.config.mjs (1 hunks)
  • plugins/pdf-extractor/tsup.config.mjs (1 hunks)
  • plugins/psv-extractor/tsup.config.mjs (1 hunks)
  • plugins/record-hook/rollup.config.mjs (0 hunks)
  • plugins/record-hook/tsup.config.mjs (1 hunks)
  • plugins/rollout/tsup.config.mjs (1 hunks)
  • plugins/space-configure/rollup.config.mjs (0 hunks)
  • plugins/space-configure/tsup.config.mjs (1 hunks)
  • plugins/sql-ddl-converter/tsup.config.mjs (1 hunks)
  • plugins/tsv-extractor/tsup.config.mjs (1 hunks)
  • plugins/view-mapped/rollup.config.mjs (0 hunks)
  • plugins/view-mapped/tsup.config.mjs (1 hunks)
  • plugins/webhook-egress/rollup.config.mjs (0 hunks)
  • plugins/webhook-egress/tsup.config.mjs (1 hunks)
  • plugins/webhook-event-forwarder/rollup.config.mjs (0 hunks)
  • plugins/webhook-event-forwarder/tsup.config.mjs (1 hunks)
  • plugins/xlsx-extractor/tsup.config.mjs (1 hunks)
  • plugins/xml-extractor/tsup.config.mjs (1 hunks)
  • plugins/yaml-schema/tsup.config.mjs (1 hunks)
  • plugins/zip-extractor/tsup.config.mjs (1 hunks)
  • support/common-utils/tsup.config.mjs (1 hunks)
  • utils/common/rollup.config.mjs (0 hunks)
  • utils/common/tsup.config.mjs (1 hunks)
  • utils/extractor/tsup.config.mjs (1 hunks)
  • utils/fetch-schema/tsup.config.mjs (1 hunks)
  • utils/file-buffer/tsup.config.mjs (1 hunks)
  • utils/response-rejection/rollup.config.mjs (0 hunks)
  • utils/response-rejection/tsup.config.mjs (1 hunks)
  • utils/testing/src/test.helpers.ts (0 hunks)
  • utils/testing/src/test.listener.ts (1 hunks)
  • utils/testing/tsup.config.mjs (1 hunks)
  • validate/boolean/rollup.config.mjs (0 hunks)
  • validate/boolean/tsup.config.mjs (1 hunks)
  • validate/date/rollup.config.mjs (0 hunks)
  • validate/date/tsup.config.mjs (1 hunks)
  • validate/email/rollup.config.mjs (0 hunks)
  • validate/email/tsup.config.mjs (1 hunks)
  • validate/isbn/rollup.config.mjs (0 hunks)
  • validate/isbn/tsup.config.mjs (1 hunks)
  • validate/number/rollup.config.mjs (0 hunks)
  • validate/number/tsup.config.mjs (1 hunks)
  • validate/phone/rollup.config.mjs (0 hunks)
  • validate/phone/tsup.config.mjs (1 hunks)
  • validate/string/jest.config.cjs (1 hunks)
  • validate/string/rollup.config.mjs (0 hunks)
  • validate/string/tsup.config.mjs (1 hunks)
💤 Files with no reviewable changes (38)
  • convert/currency/rollup.config.mjs
  • convert/translate/rollup.config.mjs
  • convert/what3words/rollup.config.mjs
  • enrich/geocode/rollup.config.mjs
  • enrich/gpx/rollup.config.mjs
  • enrich/sentiment/rollup.config.mjs
  • enrich/summarize/rollup.config.mjs
  • export/pivot-table/rollup.config.mjs
  • extract/html-table/rollup.config.mjs
  • extract/markdown/rollup.config.mjs
  • import/faker/rollup.config.mjs
  • import/llm-records/rollup.config.mjs
  • import/rss/rollup.config.mjs
  • plugins/autocast/rollup.config.mjs
  • plugins/constraints/rollup.config.mjs
  • plugins/dedupe/rollup.config.mjs
  • plugins/dxp-configure/rollup.config.mjs
  • plugins/export-workbook/rollup.config.mjs
  • plugins/foreign-db-extractor/rollup.config.mjs
  • plugins/graphql-schema/rollup.config.mjs
  • plugins/job-handler/rollup.config.mjs
  • plugins/json-extractor/rollup.config.mjs
  • plugins/openapi-schema/rollup.config.mjs
  • plugins/record-hook/rollup.config.mjs
  • plugins/space-configure/rollup.config.mjs
  • plugins/view-mapped/rollup.config.mjs
  • plugins/webhook-egress/rollup.config.mjs
  • plugins/webhook-event-forwarder/rollup.config.mjs
  • utils/common/rollup.config.mjs
  • utils/response-rejection/rollup.config.mjs
  • utils/testing/src/test.helpers.ts
  • validate/boolean/rollup.config.mjs
  • validate/date/rollup.config.mjs
  • validate/email/rollup.config.mjs
  • validate/isbn/rollup.config.mjs
  • validate/number/rollup.config.mjs
  • validate/phone/rollup.config.mjs
  • validate/string/rollup.config.mjs
✅ Files skipped from review due to trivial changes (55)
  • convert/currency/tsup.config.mjs
  • convert/translate/tsup.config.mjs
  • convert/what3words/tsup.config.mjs
  • enrich/geocode/tsup.config.mjs
  • enrich/gpx/tsup.config.mjs
  • enrich/sentiment/tsup.config.mjs
  • enrich/summarize/tsup.config.mjs
  • export/pivot-table/tsup.config.mjs
  • extract/html-table/tsup.config.mjs
  • extract/markdown/tsup.config.mjs
  • import/faker/tsup.config.mjs
  • import/llm-records/tsup.config.mjs
  • import/rss/tsup.config.mjs
  • plugins/autocast/tsup.config.mjs
  • plugins/automap/tsup.config.mjs
  • plugins/constraints/tsup.config.mjs
  • plugins/dedupe/tsup.config.mjs
  • plugins/delimiter-extractor/tsup.config.mjs
  • plugins/dxp-configure/tsup.config.mjs
  • plugins/export-workbook/tsup.config.mjs
  • plugins/foreign-db-extractor/tsup.config.mjs
  • plugins/graphql-schema/tsup.config.mjs
  • plugins/job-handler/tsup.config.mjs
  • plugins/json-extractor/tsup.config.mjs
  • plugins/json-schema/tsup.config.mjs
  • plugins/merge-connection/tsup.config.mjs
  • plugins/openapi-schema/tsup.config.mjs
  • plugins/pdf-extractor/tsup.config.mjs
  • plugins/psv-extractor/tsup.config.mjs
  • plugins/record-hook/tsup.config.mjs
  • plugins/rollout/tsup.config.mjs
  • plugins/space-configure/tsup.config.mjs
  • plugins/sql-ddl-converter/tsup.config.mjs
  • plugins/tsv-extractor/tsup.config.mjs
  • plugins/view-mapped/tsup.config.mjs
  • plugins/webhook-egress/tsup.config.mjs
  • plugins/webhook-event-forwarder/tsup.config.mjs
  • plugins/xlsx-extractor/tsup.config.mjs
  • plugins/xml-extractor/tsup.config.mjs
  • plugins/yaml-schema/tsup.config.mjs
  • plugins/zip-extractor/tsup.config.mjs
  • support/common-utils/tsup.config.mjs
  • utils/common/tsup.config.mjs
  • utils/extractor/tsup.config.mjs
  • utils/fetch-schema/tsup.config.mjs
  • utils/file-buffer/tsup.config.mjs
  • utils/response-rejection/tsup.config.mjs
  • utils/testing/tsup.config.mjs
  • validate/boolean/tsup.config.mjs
  • validate/date/tsup.config.mjs
  • validate/email/tsup.config.mjs
  • validate/isbn/tsup.config.mjs
  • validate/number/tsup.config.mjs
  • validate/phone/tsup.config.mjs
  • validate/string/tsup.config.mjs
🧰 Additional context used
🔇 Additional comments (9)
validate/string/jest.config.cjs (3)

12-16: Review test execution settings for potential issues.

The current configuration has several settings that might mask underlying issues:

  1. The 60-second timeout is quite long for unit tests. Consider reducing it unless there's a specific need for long-running tests.
  2. forceExit: true might mask cleanup issues. Consider handling cleanup properly in tests instead.
  3. passWithNoTests: true could hide missing test coverage.
#!/bin/bash
# Description: Check for existing test files and potential long-running tests

echo "Checking for test files..."
fd -e test.ts -e spec.ts -e test.tsx -e spec.tsx

echo "Checking for potential long-running tests..."
rg -l "setTimeout|setInterval" -g "*.test.ts" -g "*.spec.ts"

13-13: Verify the global setup file configuration.

The configuration references a global setup file. Let's verify its existence and examine its content for potential issues.

#!/bin/bash
# Description: Verify global setup file and its content

echo "Checking global setup file..."
if fd -p "test/setup-global.js" --type f; then
  echo "Content of global setup file:"
  cat $(fd -p "test/setup-global.js" --type f)
fi

7-11: Verify the existence and accessibility of setup files.

The configuration references several setup files using relative paths. Let's verify these files exist and are accessible.

✅ Verification successful

Let me try another verification approach with different commands to check these files.

This script will:

  1. Search for the specific setup files using ripgrep's file listing
  2. Look for references to these setup files in jest configuration files to understand the setup pattern across the project

All setup files exist and are consistently used across the project

The verification results show that:

  1. All three setup files exist in the repository:

    • test/dotenv-config.js
    • test/betterConsoleLog.js
    • test/unit.cleanup.js
  2. These setup files are consistently used across multiple Jest configurations in the project, following the same relative path pattern (../../test/) from various subdirectories. This is a standard setup pattern throughout the codebase, making it reliable and maintainable.

The relative paths in the configuration are correct and working as intended.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of referenced setup files

echo "Checking setup files..."
for file in "test/dotenv-config.js" "test/betterConsoleLog.js" "test/unit.cleanup.js"; do
  if fd -p "$file" --type f; then
    echo "✓ Found: $file"
  else
    echo "✗ Missing: $file"
  fi
done

Length of output: 694


Script:

#!/bin/bash
# Using ripgrep to search for these files in the repository
echo "Searching for setup files..."
rg --files | grep -E "test/(dotenv-config|betterConsoleLog|unit\.cleanup)\.js"

# Also check if these files are referenced in other jest configs
echo -e "\nChecking references in jest configs..."
rg "setupFiles|setupFilesAfterEnv" -A 3 -g "jest.config.*"

Length of output: 18230

bundlers/tsup-config/index.mjs (1)

1-41: Verify that the tsup configuration addresses all reported issues

The configuration looks solid but let's verify it addresses all the issues mentioned in the PR objectives:

✅ Verification successful

Let me gather more context about the PR objectives and any remaining bundler configurations by searching through the codebase.


Based on the gathered context, I can now generate the final response since we have enough information about the PR's objectives and the state of the codebase.

The tsup configuration is correctly implemented for the migration from rollup/parcel

The verification reveals that:

  • This is part of a larger migration effort from rollup to tsup as evidenced by the commit message "tsup vs rollup"
  • The tsup configuration correctly handles both Node.js and browser builds with proper output extensions
  • The repository has numerous packages already using tsup configurations (50+ tsup.config.mjs files found)
  • The configuration aligns with the monorepo structure and turbo build system

The configuration in bundlers/tsup-config/index.mjs is properly implemented as a shared configuration that:

  • Supports dual CJS/ESM output formats
  • Generates type definitions (dts)
  • Handles both Node.js and browser targets
  • Includes production mode minification
  • Uses proper file extensions for different formats (.cjs, .js, .browser.cjs, .browser.js)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the tsup configuration addresses the reported issues

# Test 1: Check if the package.json exports field is properly configured
echo "Checking package.json exports configuration..."
jq -r '.exports' package.json

# Test 2: Check for presence of type definitions in output
echo "Checking for type definitions generation..."
fd -e d.ts$ . dist/

# Test 3: Check for proper ESM/CJS output files
echo "Checking for proper module output files..."
fd -e js$ -e cjs$ . dist/

# Test 4: Check for any remaining rollup/parcel configurations
echo "Checking for old bundler configurations..."
fd -e config.js$ -e rollup.config.js$ -e .parcelrc$ .

Length of output: 728


Script:

#!/bin/bash
# Check PR description and related files for context
echo "Checking PR description and related files..."

# Look for package.json to understand the build setup
echo "Package.json contents:"
cat package.json

# Search for any build-related files
echo -e "\nSearching for build configuration files:"
fd -e json -e js -e mjs -e cjs -e yaml -e yml . | grep -iE 'build|bundle|tsup|rollup|parcel|webpack'

# Search for build scripts in package.json
echo -e "\nSearching for build scripts:"
jq -r '.scripts | to_entries | .[] | select(.key | contains("build"))' package.json

# Check if this is a new package
echo -e "\nChecking if this is a new package:"
git log --diff-filter=A -- .

Length of output: 6216

bundlers/rollup-config/index.mjs (2)

98-101: LGTM! Good organization of UMD builds.

Moving UMD builds to a dedicated subdirectory is a good practice as it:

  1. Clearly separates different module formats
  2. Prevents cluttering the main dist directory
  3. Makes it easier to exclude UMD builds from module resolution

54-57: ⚠️ Potential issue

Consider retaining .mjs extension for ESM outputs.

Given that this file generates both CommonJS and ESM outputs, using .mjs extension for ESM builds would provide clearer distinction and prevent potential resolution ambiguity. This is especially important since one of the PR objectives is to fix ESM-related issues.

Let's check if there are any module resolution patterns in the codebase that might be affected:

Consider this alternative:

-          file: 'dist/index.js',
+          file: 'dist/index.mjs',
utils/testing/src/test.listener.ts (1)

32-32: LGTM! The override keyword addition improves type safety.

The explicit override declaration aligns well with the PR's goal of improving type definitions and helps catch potential errors if the base class method signature changes.

plugins/delimiter-extractor/src/parser.ts (2)

6-6: LGTM! Import statement simplification.

The simplified import syntax is equivalent and follows common practices.


Line range hint 1-146: Verify module functionality with the new build system.

Since this is part of a build tool migration from rollup/parcel to tsup, let's verify that the module is properly bundled and exported.

✅ Verification successful

Let me gather more information to verify the build configuration since we found that the tsup config is missing.


Based on the gathered information, I can now provide a final response:

Build configuration appears correct despite missing local tsup config

The module's build setup is properly configured for the migration to tsup:

  • Package.json has correct exports configuration for both ESM and CommonJS
  • Build scripts are properly set up to use tsup ("build": "tsup")
  • No legacy build configs (rollup/parcel) remain in the codebase
  • The absence of a local tsup.config.ts is not an issue as tsup can work with default configuration

The parser module's functionality should work as expected with the new build system since:

  1. The exports are properly configured for both Node.js environments
  2. TypeScript types are correctly mapped in the exports field
  3. The build scripts are properly set up to generate the required output formats
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the module is properly bundled and exported

# Test 1: Check if the new tsup config exists
echo "Checking for tsup config..."
test -f "plugins/delimiter-extractor/tsup.config.ts" && echo "Found tsup config" || echo "Missing tsup config"

# Test 2: Verify no remaining rollup configs
echo -e "\nChecking for leftover rollup configs..."
find plugins/delimiter-extractor -name "rollup.config.*" -type f

# Test 3: Check package.json exports configuration
echo -e "\nChecking package.json exports..."
if [ -f "plugins/delimiter-extractor/package.json" ]; then
    jq '.exports' "plugins/delimiter-extractor/package.json"
fi

Length of output: 803


Script:

#!/bin/bash
# Check for build configuration in package.json and any remaining old build configs

echo "Checking package.json build scripts..."
if [ -f "plugins/delimiter-extractor/package.json" ]; then
    jq '.scripts' "plugins/delimiter-extractor/package.json"
fi

echo -e "\nChecking for any parcel configs..."
find plugins/delimiter-extractor -name ".parcelrc" -o -name "parcel.config.*" -type f

echo -e "\nChecking actual build output structure..."
if [ -d "plugins/delimiter-extractor/dist" ]; then
    ls -la plugins/delimiter-extractor/dist/
fi

echo -e "\nChecking root tsup.config if it handles all plugins..."
find . -maxdepth 1 -name "tsup.config.*"

Length of output: 1047

Comment on lines +1 to +6
module.exports = {
testEnvironment: 'node',

transform: {
'^.+\\.tsx?$': 'ts-jest',
},
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider enhancing the TypeScript configuration.

While the basic setup is correct, consider adding source map support and being more specific with the TypeScript file pattern.

 module.exports = {
   testEnvironment: 'node',
 
   transform: {
-    '^.+\\.tsx?$': 'ts-jest',
+    '^.+\\.(ts|tsx)$': ['ts-jest', {
+      tsconfig: '<rootDir>/tsconfig.json',
+      sourceMap: true
+    }],
   },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
module.exports = {
testEnvironment: 'node',
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
module.exports = {
testEnvironment: 'node',
transform: {
'^.+\\.(ts|tsx)$': ['ts-jest', {
tsconfig: '<rootDir>/tsconfig.json',
sourceMap: true
}],
},

Comment on lines 39 to 41
export function defineConfig({ includeBrowser = true }) {
return tsupDefineConfig(includeBrowser ? [nodeConfig, browserConfig] : [nodeConfig])
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider enhancing configuration options

The defineConfig function could be more flexible by accepting additional configuration options to customize the base settings.

-export function defineConfig({ includeBrowser = true }) {
+export function defineConfig({
+  includeBrowser = true,
+  entryPoints = ['src/index.ts'],
+  outDir = 'dist',
+  ...customConfig
+}) {
+  const configs = [
+    { ...nodeConfig, entryPoints, outDir, ...customConfig },
+    ...(includeBrowser ? [{ ...browserConfig, entryPoints, outDir, ...customConfig }] : []),
+  ]
+
+  // Validate configurations
+  for (const config of configs) {
+    if (!config.entryPoints?.length) {
+      throw new Error('At least one entry point must be specified')
+    }
+  }
+
+  return tsupDefineConfig(configs)
 }

Committable suggestion was skipped due to low confidence.

Comment on lines 11 to 23
const nodeConfig = {
name: 'node',
platform: 'node',
minify: process.env.NODE_ENV === 'production',
entryPoints: ['src/index.ts'],
format: ['cjs', 'esm'],
dts: true,
outDir: 'dist',
clean: true,
outExtension: ({ format }) => ({
js: format === 'cjs' ? '.cjs' : '.js',
}),
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider additional bundler optimizations

The Node.js configuration is good but could benefit from additional optimizations:

 const nodeConfig = {
   name: 'node',
   platform: 'node',
   minify: process.env.NODE_ENV === 'production',
   entryPoints: ['src/index.ts'],
   format: ['cjs', 'esm'],
   dts: true,
   outDir: 'dist',
   clean: true,
+  sourcemap: true,
+  treeshake: true,
   outExtension: ({ format }) => ({
     js: format === 'cjs' ? '.cjs' : '.js',
   }),
 }

Consider also making the entry points configurable through the defineConfig options to support different package structures.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const nodeConfig = {
name: 'node',
platform: 'node',
minify: process.env.NODE_ENV === 'production',
entryPoints: ['src/index.ts'],
format: ['cjs', 'esm'],
dts: true,
outDir: 'dist',
clean: true,
outExtension: ({ format }) => ({
js: format === 'cjs' ? '.cjs' : '.js',
}),
}
const nodeConfig = {
name: 'node',
platform: 'node',
minify: process.env.NODE_ENV === 'production',
entryPoints: ['src/index.ts'],
format: ['cjs', 'esm'],
dts: true,
outDir: 'dist',
clean: true,
sourcemap: true,
treeshake: true,
outExtension: ({ format }) => ({
js: format === 'cjs' ? '.cjs' : '.js',
}),
}

Comment on lines 25 to 37
const browserConfig = {
name: 'browser',
platform: 'browser',
minify: process.env.NODE_ENV === 'production',
entryPoints: ['src/index.ts'],
format: ['cjs', 'esm'],
dts: true,
outDir: 'dist',
clean: true,
outExtension: ({ format }) => ({
js: format === 'cjs' ? '.browser.cjs' : '.browser.js',
}),
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Reduce configuration duplication

The browser configuration largely duplicates the Node.js configuration. Consider creating a base configuration to improve maintainability.

+const baseConfig = {
+  minify: process.env.NODE_ENV === 'production',
+  entryPoints: ['src/index.ts'],
+  format: ['cjs', 'esm'],
+  dts: true,
+  outDir: 'dist',
+  clean: true,
+  sourcemap: true,
+  treeshake: true,
+}

 const nodeConfig = {
+  ...baseConfig,
   name: 'node',
   platform: 'node',
-  minify: process.env.NODE_ENV === 'production',
-  entryPoints: ['src/index.ts'],
-  format: ['cjs', 'esm'],
-  dts: true,
-  outDir: 'dist',
-  clean: true,
   outExtension: ({ format }) => ({
     js: format === 'cjs' ? '.cjs' : '.js',
   }),
 }

 const browserConfig = {
+  ...baseConfig,
   name: 'browser',
   platform: 'browser',
-  minify: process.env.NODE_ENV === 'production',
-  entryPoints: ['src/index.ts'],
-  format: ['cjs', 'esm'],
-  dts: true,
-  outDir: 'dist',
-  clean: true,
   outExtension: ({ format }) => ({
     js: format === 'cjs' ? '.browser.cjs' : '.browser.js',
   }),
 }

Committable suggestion was skipped due to low confidence.

Comment on lines +75 to 78
file: 'dist/index.browser.js',
sourcemap: false,
format: 'es',
},
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Consider retaining .mjs extension for browser ESM output.

Similar to the Node.js build, using .mjs extension for browser ESM builds would maintain consistency and prevent resolution ambiguity.

Consider this alternative:

-                file: 'dist/index.browser.js',
+                file: 'dist/index.browser.mjs',
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
file: 'dist/index.browser.js',
sourcemap: false,
format: 'es',
},
file: 'dist/index.browser.mjs',
sourcemap: false,
format: 'es',
},

Comment on lines 19 to 21
? false
: options?.skipEmptyLines ?? false
: (options?.skipEmptyLines ?? false)
const fileContents = buffer.toString('utf8')
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider simplifying the conditional expression.

While the current implementation with parentheses is correct, the expression could be more concise.

Consider this alternative:

-    const skipEmptyLines = options?.headerSelectionEnabled
-      ? false
-      : (options?.skipEmptyLines ?? false)
+    const skipEmptyLines = options?.headerSelectionEnabled ? false : options?.skipEmptyLines ?? false

Or even better, using logical operators:

-    const skipEmptyLines = options?.headerSelectionEnabled
-      ? false
-      : (options?.skipEmptyLines ?? false)
+    const skipEmptyLines = !options?.headerSelectionEnabled && (options?.skipEmptyLines ?? false)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
? false
: options?.skipEmptyLines ?? false
: (options?.skipEmptyLines ?? false)
const fileContents = buffer.toString('utf8')
const skipEmptyLines = options?.headerSelectionEnabled ? false : options?.skipEmptyLines ?? false
const fileContents = buffer.toString('utf8')
```
Option 2 (using logical operators):
```suggestion
const skipEmptyLines = !options?.headerSelectionEnabled && (options?.skipEmptyLines ?? false)
const fileContents = buffer.toString('utf8')

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (2)
plugins/record-hook/tsup.config.mjs (1)

10-13: LGTM! Configuration addresses PR objectives.

The configuration properly sets up both ESM and UMD builds with consistent naming. The defineConfig setup with explicit UMD configuration should resolve the ESM masquerading issues mentioned in the PR objectives.

Consider documenting the following in the repository's README or contributing guidelines:

  1. The purpose of globalName in the UMD context
  2. When and why developers should use includeUmd
  3. The relationship between this configuration and the package.json exports field

This will help future contributors understand the build configuration choices.

bundlers/tsup-config/index.mjs (1)

12-15: Consider using a more structured logging approach.

While the minification logic is correct, using console.log directly might not be ideal for configuration feedback.

Consider using a more structured logging approach:

-  if (!minify) {
-    console.log('Not in production mode - skipping minification')
-  }
+  if (!minify) {
+    process.stderr.write('\x1b[33mWarning: Not in production mode - skipping minification\x1b[0m\n')
+  }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 8b6dd51 and 366f5e4.

⛔ Files ignored due to path filters (3)
  • package-lock.json is excluded by !**/package-lock.json, !**/*.json
  • package.json is excluded by !**/*.json
  • plugins/record-hook/package.json is excluded by !**/*.json
📒 Files selected for processing (2)
  • bundlers/tsup-config/index.mjs (1 hunks)
  • plugins/record-hook/tsup.config.mjs (2 hunks)
🔇 Additional comments (4)
plugins/record-hook/tsup.config.mjs (1)

Line range hint 1-8: LGTM! Verify completeness of UMD externals.

The migration to @flatfile/bundler-config-tsup aligns with the PR objectives. The UMD externals list appears comprehensive, including core Flatfile dependencies.

Let's verify if all required externals are included:

✅ Verification successful

Based on the results from the shell script, I can now generate the final response since I have all the necessary information to verify the UMD externals list.

UMD externals list is complete and accurate

The externals list in tsup.config.mjs perfectly matches all the @flatfile/* dependencies imported across the source files:

  • @flatfile/api
  • @flatfile/hooks
  • @flatfile/listener
  • @flatfile/util-common
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for potential missing externals by finding imports in the source files

# Find the source directory for this plugin
SRC_DIR=$(fd -t d "src$" --max-depth 2 plugins/record-hook)

# Search for import statements in source files
echo "Analyzing imports in source files:"
rg "^import .+ from ['\"](@flatfile/[^'\"]+)" "$SRC_DIR" --only-matching --replace '$1' || true

Length of output: 1035

bundlers/tsup-config/index.mjs (3)

1-4: LGTM! Well-structured imports and environment setup.

The imports are clean and the environment configuration is properly handled.


6-11: LGTM! Well-designed configuration interface.

The function signature provides good flexibility with sensible defaults, supporting all necessary build targets (Node.js, browser, UMD).


1-73: Verify the bundler configuration across different package types.

The configuration looks solid and aligns well with the PR objectives. However, it's crucial to verify that it works correctly across different package types in the repository.

Let's verify the configuration:

Comment on lines 17 to 39
const nodeConfig = {
name: 'node',
platform: 'node',
minify,
entryPoints: ['src/index.ts'],
format: ['cjs', 'esm'],
dts: true,
outDir: 'dist',
clean: true,
outExtension: ({ format }) => ({
js: format === 'cjs' ? '.cjs' : '.js',
}),
}

if (includeUmd) {
nodeConfig.format.push('iife')
nodeConfig.globalName = umdConfig.name
nodeConfig.outExtension = ({ format }) => ({
js: format === 'cjs' ? '.cjs' : format === 'iife' ? '.umd.js' : '.js',
})
nodeConfig.external = umdConfig.external
}

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider enabling source maps and tree shaking.

While the Node.js configuration is solid, it could benefit from additional optimizations for better debugging and smaller bundles.

Consider adding these optimizations:

 const nodeConfig = {
   name: 'node',
   platform: 'node',
   minify,
   entryPoints: ['src/index.ts'],
   format: ['cjs', 'esm'],
   dts: true,
   outDir: 'dist',
   clean: true,
+  sourcemap: true,
+  treeshake: true,
   outExtension: ({ format }) => ({
     js: format === 'cjs' ? '.cjs' : '.js',
   }),
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const nodeConfig = {
name: 'node',
platform: 'node',
minify,
entryPoints: ['src/index.ts'],
format: ['cjs', 'esm'],
dts: true,
outDir: 'dist',
clean: true,
outExtension: ({ format }) => ({
js: format === 'cjs' ? '.cjs' : '.js',
}),
}
if (includeUmd) {
nodeConfig.format.push('iife')
nodeConfig.globalName = umdConfig.name
nodeConfig.outExtension = ({ format }) => ({
js: format === 'cjs' ? '.cjs' : format === 'iife' ? '.umd.js' : '.js',
})
nodeConfig.external = umdConfig.external
}
const nodeConfig = {
name: 'node',
platform: 'node',
minify,
entryPoints: ['src/index.ts'],
format: ['cjs', 'esm'],
dts: true,
outDir: 'dist',
clean: true,
sourcemap: true,
treeshake: true,
outExtension: ({ format }) => ({
js: format === 'cjs' ? '.cjs' : '.js',
}),
}
if (includeUmd) {
nodeConfig.format.push('iife')
nodeConfig.globalName = umdConfig.name
nodeConfig.outExtension = ({ format }) => ({
js: format === 'cjs' ? '.cjs' : format === 'iife' ? '.umd.js' : '.js',
})
nodeConfig.external = umdConfig.external
}

Comment on lines 68 to 73
const configs = []
if (includeNode) configs.push(nodeConfig)
if (includeBrowser) configs.push(browserConfig)

return tsupDefineConfig(configs)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider adding configuration validation.

While the config selection is clean, it would be beneficial to validate the configuration before returning it.

Consider adding validation:

 const configs = []
 if (includeNode) configs.push(nodeConfig)
 if (includeBrowser) configs.push(browserConfig)

+if (configs.length === 0) {
+  throw new Error('At least one build target (Node.js or browser) must be enabled')
+}
+
+if (includeUmd && !umdConfig.name) {
+  throw new Error('UMD builds require a global name to be specified')
+}

 return tsupDefineConfig(configs)

Committable suggestion was skipped due to low confidence.

Comment on lines 40 to 66
const browserConfig = {
name: 'browser',
platform: 'browser',
minify,
entryPoints: ['src/index.ts'],
format: ['cjs', 'esm'],
dts: true,
outDir: 'dist',
clean: true,
outExtension: ({ format }) => ({
js: format === 'cjs' ? '.browser.cjs' : '.browser.js',
}),
}

if (includeUmd) {
browserConfig.format.push('iife')
browserConfig.globalName = umdConfig.name
browserConfig.outExtension = ({ format }) => ({
js:
format === 'cjs'
? '.browser.cjs'
: format === 'iife'
? '.browser.umd.js'
: '.browser.js',
})
browserConfig.external = umdConfig.external
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider extracting common configuration.

There's significant duplication between the Node.js and browser configurations that could be reduced.

Consider using a base configuration:

+const baseConfig = {
+  minify,
+  entryPoints: ['src/index.ts'],
+  format: ['cjs', 'esm'],
+  dts: true,
+  outDir: 'dist',
+  clean: true,
+  sourcemap: true,
+  treeshake: true,
+}

 const browserConfig = {
+  ...baseConfig,
   name: 'browser',
   platform: 'browser',
-  minify,
-  entryPoints: ['src/index.ts'],
-  format: ['cjs', 'esm'],
-  dts: true,
-  outDir: 'dist',
-  clean: true,
   outExtension: ({ format }) => ({
     js: format === 'cjs' ? '.browser.cjs' : '.browser.js',
   }),
 }

Committable suggestion was skipped due to low confidence.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Outside diff range and nitpick comments (7)
plugins/merge-connection/src/merge.plugin.ts (1)

Line range hint 1-27: Consider adding JSDoc documentation for better API clarity.

While the code structure is clean, adding JSDoc documentation would improve API clarity, especially since this is a plugin interface.

Consider adding documentation like this:

+/**
+ * Creates a Merge plugin instance that handles workbook creation and synchronization
+ * with Merge API endpoints.
+ * 
+ * @returns A plugin configuration function that sets up Merge-related job handlers
+ */
export function mergePlugin() {
bundlers/tsup-config/index.mjs (2)

6-10: Consider enhancing the debug logging.

While the production mode check is good, the logging could be more informative.

-    console.log('Not in production mode - skipping minification')
+    console.log(`Building in ${process.env.NODE_ENV || 'development'} mode - minification disabled`)

6-52: Consider supporting environment-specific configurations.

The configuration could be enhanced to support different settings based on the environment (development, staging, production) beyond just minification.

This could include:

  • Environment-specific entry points
  • Different external dependency handling per environment
  • Custom plugins or transforms per environment
  • Environment-specific output directories

Would you like me to provide an example implementation?

plugins/constraints/src/external.constraint.ts (1)

Line range hint 24-29: Consider optimizing schema caching strategy.

The current implementation initializes the cache on every 'commit:created' event with a TODO comment about longer caching duration. Consider implementing a more persistent caching strategy to reduce API calls and improve performance.

Suggestions:

  1. Implement a TTL-based caching mechanism
  2. Consider using a shared cache across events
  3. Add cache invalidation on schema updates
plugins/merge-connection/README.md (2)

33-33: Fix spacing in TypeScript import statement.

For consistency with the JavaScript example above, add a space after the opening brace.

-import {mergePlugin } from "@flatfile/plugin-connect-via-merge";
+import { mergePlugin } from "@flatfile/plugin-connect-via-merge";

Line range hint 1-15: Fix step numbering in prerequisites.

The steps are currently numbered as 1, 2, 4, 3. Please reorder them sequentially.

1. Email support@flatfile.com to request that the `connections` flag be enabled for your account.
2. Create a [Merge.dev](https://www.merge.dev) account.
-4. Create and configure a [Flatfile Space](https://platform.flatfile.com).
-3. Create a new secret named `MERGE_ACCESS_KEY` in your space containing your [Merge.dev API key](https://app.merge.dev/keys).
+3. Create and configure a [Flatfile Space](https://platform.flatfile.com).
+4. Create a new secret named `MERGE_ACCESS_KEY` in your space containing your [Merge.dev API key](https://app.merge.dev/keys).
bundlers/rollup-config/index.mjs (1)

Line range hint 1-117: Clarify the migration strategy from Rollup to tsup.

While the changes improve the Rollup configuration, they seem to contradict the PR's objective of replacing Rollup with tsup. Consider:

  1. Adding a deprecation notice to this file
  2. Documenting the migration strategy (gradual vs. immediate)
  3. Creating a mapping between current Rollup config options and their tsup equivalents
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 2ddd0a8 and 92e8bef.

⛔ Files ignored due to path filters (3)
  • package-lock.json is excluded by !**/package-lock.json, !**/*.json
  • package.json is excluded by !**/*.json
  • plugins/record-hook/package.json is excluded by !**/*.json
📒 Files selected for processing (10)
  • bundlers/rollup-config/index.mjs (3 hunks)
  • bundlers/tsup-config/index.mjs (1 hunks)
  • plugins/autocast/src/autocast.plugin.ts (2 hunks)
  • plugins/constraints/src/external.constraint.ts (2 hunks)
  • plugins/constraints/src/external.sheet.constraint.ts (2 hunks)
  • plugins/merge-connection/README.md (2 hunks)
  • plugins/merge-connection/src/index.ts (1 hunks)
  • plugins/merge-connection/src/merge.plugin.ts (2 hunks)
  • plugins/record-hook/rollup.config.mjs (2 hunks)
  • plugins/record-hook/tsup.config.mjs (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • plugins/merge-connection/src/index.ts
🔇 Additional comments (18)
plugins/record-hook/tsup.config.mjs (1)

1-3: Verify default configuration meets PR objectives.

The empty configuration relies entirely on defaults from @flatfile/bundler-config-tsup. Please verify that the default configuration:

  • Generates both ESM and CJS outputs correctly
  • Includes proper type definitions
  • Sets up correct export conditions
  • Prevents ESM masquerading issues
✅ Verification successful

Let me gather more information about the default configuration by examining the package and other build configurations.


Let me check the actual tsup configuration implementation to understand the defaults.


Empty configuration is correct and matches PR objectives

The default configuration from @flatfile/bundler-config-tsup fully addresses the PR objectives:

  1. Generates both ESM and CJS outputs with correct extensions:
    • Node: .js (ESM) and .cjs (CommonJS)
    • Browser: .browser.js (ESM) and .browser.cjs (CommonJS)
  2. Includes type definitions with proper extensions (.d.ts and .d.cts)
  3. Aligns perfectly with package.json exports configuration
  4. Includes optimizations: sourcemaps, treeshaking, and code splitting
  5. Prevents ESM masquerading through explicit extension mapping

The empty config {} is intentional as the defaults are carefully designed to handle the migration requirements.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the default config is documented
rg -A 10 "defineConfig" -g "*.md" || echo "No documentation found for defineConfig"

# Look for similar tsup configs in other plugins for consistency
fd -e "tsup.config.mjs" -x cat {} \; 

Length of output: 162


Script:

#!/bin/bash
# Check the package.json for build configuration and dependencies
cat plugins/record-hook/package.json

# Look for the bundler-config-tsup package contents
rg -g "!node_modules" "@flatfile/bundler-config-tsup" -A 5

# Check for any existing build configurations in the repository
rg "defineConfig" -g "*.{js,mjs,ts}" -A 10

Length of output: 49692


Script:

#!/bin/bash
# Check the bundler-config-tsup implementation
cat bundlers/tsup-config/index.mjs

# Check package.json exports configuration to verify alignment
cat plugins/record-hook/package.json | jq '.exports'

Length of output: 1786

plugins/record-hook/rollup.config.mjs (3)

14-15: Verify UMD-only build strategy.

The configuration only enables UMD builds while disabling other formats. This might limit the module's usage in modern environments that prefer ESM.

Let's check for potential UMD dependencies:

#!/bin/bash
# Check if the external dependencies support UMD format
for pkg in "@flatfile/api" "@flatfile/hooks" "@flatfile/listener" "@flatfile/util-common"; do
  echo "Checking $pkg..."
  cat node_modules/$pkg/package.json | jq '.exports, .main, .module'
done

11-13: Verify the implications of disabled builds.

Disabling Node.js, browser, and type definition builds raises concerns:

  1. How will this affect package consumers who need Node.js or browser environments?
  2. Disabling type definitions (includeDefinitions: false) seems to contradict the PR objective of fixing "absence of type definitions"

Let's check the package.json configuration:

#!/bin/bash
# Check if package.json has appropriate exports configuration
cat plugins/record-hook/package.json | jq '.exports, .main, .module, .types'

# Verify if there are existing type definitions that might be affected
fd -e d.ts . plugins/record-hook/

1-1: LGTM! Note about transition phase.

The import change aligns with the PR objectives. However, since the end goal is to replace Rollup with tsup, this seems to be a transitional change.

Let's verify if this is the only remaining Rollup config:

✅ Verification successful

Transition from Rollup to tsup is in progress

The verification shows that:

  • Most packages have already migrated to tsup (numerous tsup.config.mjs files)
  • Only plugins/record-hook has both rollup.config.mjs and tsup.config.mjs, indicating it's in transition
  • The bundler configuration is maintained in bundlers/rollup-config

This confirms that the import change is part of the ongoing migration from Rollup to tsup, and this file will likely be removed once the transition is complete.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other rollup config files that might need similar updates
fd -e mjs -e js -e ts rollup.config

Length of output: 850


Script:

#!/bin/bash
# Let's try a different approach to find rollup configs
rg -l "rollup\.config"

# Also search for any rollup-related imports or configurations
rg -l "@rollup|buildConfig"

# Check if there are other build configuration files
fd -e config.js -e config.mjs -e config.ts

Length of output: 2234

plugins/merge-connection/src/merge.plugin.ts (1)

Line range hint 6-25: LGTM: Clean export modification aligns with ESM standards.

The conversion from default export to named export follows modern ESM best practices while maintaining clear function semantics.

bundlers/tsup-config/index.mjs (3)

1-4: LGTM! Environment setup is properly configured.

The imports are well-organized and environment variables are loaded at the appropriate time.


12-21: LGTM! Extension mapping is well-structured.

The extension mapping is clear, follows conventions, and properly separates browser and node outputs.


47-52: Add configuration validation.

I agree with the previous review comment about adding validation. It's important to ensure at least one configuration is selected and validate the configuration options.

plugins/constraints/src/external.constraint.ts (2)

4-4: Verify package.json compatibility with the updated import.

The change from bulkRecordHookPlugin to bulkRecordHook needs to be reflected in the package's exports configuration to ensure proper ESM/CJS compatibility.

Let's verify the package configuration:

#!/bin/bash
# Description: Check package.json exports configuration and dependencies

# Test 1: Check if @flatfile/plugin-record-hook is properly declared in dependencies
jq '.dependencies["@flatfile/plugin-record-hook"]' package.json

# Test 2: Verify exports configuration in plugin-record-hook package
cat node_modules/@flatfile/plugin-record-hook/package.json 2>/dev/null | jq '.exports'

33-33: Implementation change looks good.

The update to use bulkRecordHook maintains the same functionality while aligning with the new API. The error handling, caching mechanism, and callback structure remain properly implemented.

Let's verify there are no remaining references to the old API:

✅ Verification successful

Migration to bulkRecordHook is properly implemented

The verification shows that:

  • No references to the old bulkRecordHookPlugin exist in the codebase
  • The new bulkRecordHook is properly imported from '@flatfile/plugin-record-hook'
  • The API is consistently used across multiple files including tests, constraints, and plugins
  • The implementation maintains the expected function signature and usage pattern
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining references to bulkRecordHookPlugin

# Test: Search for any remaining usage of the old API name
rg "bulkRecordHookPlugin" --type ts

Length of output: 145


Script:

#!/bin/bash
# Let's verify if the new API 'bulkRecordHook' is properly imported and available
rg "import.*bulkRecordHook" --type ts -A 2

# Also check for any direct usage of bulkRecordHook in the codebase
rg "bulkRecordHook\(" --type ts -A 2

Length of output: 5929

plugins/merge-connection/README.md (1)

Line range hint 23-27: LGTM! Import statement correctly updated.

The change to use named imports aligns with the module's new export structure.

plugins/constraints/src/external.sheet.constraint.ts (2)

42-42: Implementation looks good, but verify runtime behavior.

The switch to bulkRecordHook maintains the same functionality while aligning with the new standardized API. The error handling and record processing remain robust.

#!/bin/bash
# Description: Verify the exported types and runtime behavior
# by checking if bulkRecordHook is properly exported

echo "Checking if bulkRecordHook is properly exported from @flatfile/plugin-record-hook..."
ast-grep --pattern 'export { $_ as bulkRecordHook }'

echo "Verifying type definitions exist..."
fd -e d.ts -x cat {} \; | rg "bulkRecordHook.*:"

5-5: Verify consistent usage of bulkRecordHook across the codebase.

The import change from bulkRecordHookPlugin to bulkRecordHook appears to be part of standardizing the API. Let's verify this change is consistent across all files.

✅ Verification successful

Import change from bulkRecordHookPlugin to bulkRecordHook is correct and consistent

The search results confirm that:

  1. bulkRecordHook is the correct export name, aliased from bulkRecordHookPlugin in the source (plugins/record-hook/src/record.hook.plugin.ts)
  2. All imports across the codebase consistently use bulkRecordHook from '@flatfile/plugin-record-hook'
  3. The documentation and examples in README.md also use the bulkRecordHook naming
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining usage of bulkRecordHookPlugin
# to ensure complete migration to bulkRecordHook

echo "Checking for any remaining references to bulkRecordHookPlugin..."
rg "bulkRecordHookPlugin"

echo "Verifying consistent import pattern for bulkRecordHook..."
rg "import.*bulkRecordHook.*from.*@flatfile/plugin-record-hook"

Length of output: 368


Script:

#!/bin/bash
# Let's try a more comprehensive search strategy

# 1. Search for any references to bulkRecordHookPlugin or bulkRecordHook
echo "Searching for all references to bulk record hooks..."
rg -i "bulkrecord.*hook"

# 2. Check imports specifically from @flatfile/plugin-record-hook
echo -e "\nChecking imports from plugin-record-hook..."
rg "from ['|\"]@flatfile/plugin-record-hook"

# 3. Look for the export in the plugin-record-hook package
echo -e "\nChecking exports in plugin-record-hook..."
fd -g "*record-hook*.ts" -x cat {}

Length of output: 9227

bundlers/rollup-config/index.mjs (2)

Line range hint 108-114: Verify UMD build requirements.

As we migrate to tsup, please confirm if UMD builds are still required. If they are, ensure tsup's UMD output capabilities meet your needs.

Let's check if UMD builds are referenced in package.json:

#!/bin/bash
# Search for UMD references in package.json files
rg "umd" -A 5 -g "package.json"

92-100: Verify type definition strategy with tsup migration.

Since we're transitioning to tsup, verify that this type definition generation strategy aligns with tsup's capabilities. Tsup has built-in type declaration generation that might be more efficient.

Let's check if tsup type generation is configured elsewhere:

plugins/autocast/src/autocast.plugin.ts (3)

5-5: LGTM: Import statement update aligns with module standardization.

The change from bulkRecordHookPlugin to bulkRecordHook is consistent with the PR's objective to improve module handling and standardize exports.


21-21: LGTM: Function usage updated to match import change.

The usage of bulkRecordHook correctly reflects the updated import name while maintaining the same functionality.


Line range hint 1-4: Verify type exports configuration for imported types.

Since this PR focuses on fixing module-related issues and ensuring proper exports, let's verify that the imported types are properly configured in the package's exports section.

✅ Verification successful

Type exports are properly configured

The package.json shows a comprehensive type export configuration that properly handles both ESM and CJS environments:

  • Types are correctly exported via the "types" field
  • The "exports" field includes proper type definitions for both import and require
  • Type definitions are properly mapped for both node and browser environments
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check package.json exports configuration for proper type definitions

# Test 1: Check if types are properly configured in package.json
echo "Checking package.json exports configuration..."
jq '.exports | select(. != null)' package.json

# Test 2: Verify that @arethetypeswrong/cli reports no issues
echo "Checking for type export issues..."
npx @arethetypeswrong/cli .

Length of output: 332


Script:

#!/bin/bash
# Let's check the package.json content directly and look for type-related configurations
echo "Checking package.json content..."
cat plugins/autocast/package.json

# Also check for any tsconfig.json that might define type exports
echo -e "\nChecking for tsconfig.json..."
fd tsconfig.json plugins/autocast/

echo -e "\nChecking tsconfig.json content if exists..."
cat plugins/autocast/tsconfig.json 2>/dev/null || echo "tsconfig.json not found"

# Check if the types are actually being generated
echo -e "\nChecking for type definition files..."
fd -e d.ts . plugins/autocast/

Length of output: 2634

@@ -0,0 +1,3 @@
import { defineConfig } from '@flatfile/bundler-config-tsup'

export default defineConfig({})
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider adding explicit configuration options.

To ensure all PR objectives are met and maintain clarity for future maintenance, consider explicitly configuring:

-export default defineConfig({})
+export default defineConfig({
+  // Specify entry points
+  entry: ['src/index.ts'],
+  
+  // Generate both ESM and CJS formats
+  format: ['esm', 'cjs'],
+  
+  // Ensure type definitions are generated
+  dts: true,
+  
+  // Clean output directory before builds
+  clean: true,
+  
+  // Configure package exports
+  outDir: 'dist'
+})
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export default defineConfig({})
export default defineConfig({
// Specify entry points
entry: ['src/index.ts'],
// Generate both ESM and CJS formats
format: ['esm', 'cjs'],
// Ensure type definitions are generated
dts: true,
// Clean output directory before builds
clean: true,
// Configure package exports
outDir: 'dist'
})

}
}

export default mergePlugin
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Export pattern is inconsistent and needs to be fixed

The codebase analysis reveals inconsistencies in the export/import patterns:

  • The module has both named and default exports of mergePlugin
  • The README shows named imports import { mergePlugin }
  • The index file re-exports it as a namespace export * as mergePlugin

This creates ambiguity and potential compatibility issues. Recommend:

  • Either use named export only: export function mergePlugin()
  • Or default export only: export default mergePlugin
  • Update the index.ts re-export accordingly
  • Update the README examples to match the chosen pattern
🔗 Analysis chain

Verify the export compatibility across the codebase.

The dual-export pattern (both named and default) is a good approach for maintaining backward compatibility during the build tool transition.

Let's verify the import usage across the codebase to ensure the export changes don't break existing code:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for existing import patterns of mergePlugin
# This helps ensure the export changes don't break existing usage

# Search for both default and named import patterns
echo "Checking import patterns for mergePlugin..."
rg -A 1 "import.*mergePlugin.*from.*@flatfile/plugin-connect-via-merge"

# Check if there are any dynamic imports that might be affected
echo "Checking dynamic imports..."
rg "import\\(.*plugin-connect-via-merge.*\\)"

Length of output: 557


Script:

#!/bin/bash
# Let's check the actual implementation to see if there are any named exports
echo "Checking the implementation file for exports..."
cat plugins/merge-connection/src/merge.plugin.ts

# Also check if there are any other files importing from this module within the repository
echo "Checking local imports..."
rg "from ['\"]\.\.?/.*merge\.plugin['\"]"

Length of output: 1306

Comment on lines 29 to 42
const createConfig = (platform) => ({
name: platform,
platform,
minify,
entryPoints: ['src/index.ts'],
format: ['cjs', 'esm'],
dts: true,
outDir: 'dist',
clean: true,
sourcemap: true,
treeshake: true,
splitting: true,
outExtension: getOutExtension(platform),
})
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider handling external dependencies.

The configuration is well-structured but missing external dependency handling, which is important for proper bundling.

 const createConfig = (platform) => ({
   name: platform,
   platform,
   minify,
   entryPoints: ['src/index.ts'],
   format: ['cjs', 'esm'],
   dts: true,
   outDir: 'dist',
   clean: true,
   sourcemap: true,
   treeshake: true,
   splitting: true,
+  external: [
+    // Node.js built-ins
+    ...Object.keys(process.binding('natives')),
+    // Dependencies from package.json
+    ...Object.keys(require('./package.json').dependencies || {}),
+    ...Object.keys(require('./package.json').peerDependencies || {}),
+  ],
   outExtension: getOutExtension(platform),
 })

Committable suggestion was skipped due to low confidence.

Comment on lines +51 to +61
{
exports: 'auto',
file: 'dist/index.cjs',
format: 'cjs',
},
{
exports: 'auto',
file: 'dist/index.js',
sourcemap: false,
format: 'es',
},
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Review module resolution strategy.

The current extension changes might cause module resolution ambiguity:

  1. Using .js for ESM modules (line 58) can be ambiguous as .js is traditionally associated with CommonJS
  2. While adding .cjs for CommonJS is explicit (line 53), consider keeping .mjs for ESM to maintain explicit module type indicators

Consider this modification:

  {
    exports: 'auto',
-   file: 'dist/index.js',
+   file: 'dist/index.mjs',
    sourcemap: false,
    format: 'es',
  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{
exports: 'auto',
file: 'dist/index.cjs',
format: 'cjs',
},
{
exports: 'auto',
file: 'dist/index.js',
sourcemap: false,
format: 'es',
},
{
exports: 'auto',
file: 'dist/index.cjs',
format: 'cjs',
},
{
exports: 'auto',
file: 'dist/index.mjs',
sourcemap: false,
format: 'es',
},

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
bundlers/rollup-config/index.mjs (2)

38-42: Consider deprecating this configuration.

Given that the PR objective is to migrate from Rollup to tsup, enhancing the Rollup configuration with new features contradicts the migration strategy. Instead:

  1. Add a deprecation notice
  2. Document the migration path to tsup
  3. Remove this configuration once all packages have migrated
+// @deprecated Use @flatfile/bundler-config-tsup instead.
+// This configuration will be removed once all packages have migrated to tsup.
 export function buildConfig({
   external = [],
   includeNode = true,
   includeBrowser = true,
   includeDefinitions = true,
   includeUmd = false,
   umdConfig = { name: undefined, external: [] },
 })

Line range hint 1-117: Consider gradual migration approach.

Since this is part of a larger migration from Rollup to tsup, consider:

  1. Adding a migration guide in the README
  2. Creating a coexistence period where both bundlers work
  3. Setting up a deprecation timeline
  4. Adding automated tests to verify build output consistency between both bundlers

This will help ensure a smooth transition while maintaining backward compatibility.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 92e8bef and 75df9cb.

⛔ Files ignored due to path filters (58)
  • convert/currency/package.json is excluded by !**/*.json
  • convert/translate/package.json is excluded by !**/*.json
  • convert/what3words/package.json is excluded by !**/*.json
  • enrich/geocode/package.json is excluded by !**/*.json
  • enrich/gpx/package.json is excluded by !**/*.json
  • enrich/sentiment/package.json is excluded by !**/*.json
  • enrich/summarize/package.json is excluded by !**/*.json
  • export/pivot-table/package.json is excluded by !**/*.json
  • extract/html-table/package.json is excluded by !**/*.json
  • extract/markdown/package.json is excluded by !**/*.json
  • import/faker/package.json is excluded by !**/*.json
  • import/llm-records/package.json is excluded by !**/*.json
  • import/rss/package.json is excluded by !**/*.json
  • package-lock.json is excluded by !**/package-lock.json, !**/*.json
  • package.json is excluded by !**/*.json
  • plugins/autocast/package.json is excluded by !**/*.json
  • plugins/automap/package.json is excluded by !**/*.json
  • plugins/constraints/package.json is excluded by !**/*.json
  • plugins/dedupe/package.json is excluded by !**/*.json
  • plugins/delimiter-extractor/package.json is excluded by !**/*.json
  • plugins/dxp-configure/package.json is excluded by !**/*.json
  • plugins/export-workbook/package.json is excluded by !**/*.json
  • plugins/foreign-db-extractor/package.json is excluded by !**/*.json
  • plugins/graphql-schema/package.json is excluded by !**/*.json
  • plugins/job-handler/package.json is excluded by !**/*.json
  • plugins/json-extractor/package.json is excluded by !**/*.json
  • plugins/json-schema/package.json is excluded by !**/*.json
  • plugins/merge-connection/package.json is excluded by !**/*.json
  • plugins/openapi-schema/package.json is excluded by !**/*.json
  • plugins/pdf-extractor/package.json is excluded by !**/*.json
  • plugins/psv-extractor/package.json is excluded by !**/*.json
  • plugins/record-hook/package.json is excluded by !**/*.json
  • plugins/rollout/package.json is excluded by !**/*.json
  • plugins/space-configure/package.json is excluded by !**/*.json
  • plugins/sql-ddl-converter/package.json is excluded by !**/*.json
  • plugins/tsv-extractor/package.json is excluded by !**/*.json
  • plugins/view-mapped/package.json is excluded by !**/*.json
  • plugins/webhook-egress/package.json is excluded by !**/*.json
  • plugins/webhook-event-forwarder/package.json is excluded by !**/*.json
  • plugins/xlsx-extractor/package.json is excluded by !**/*.json
  • plugins/xml-extractor/package.json is excluded by !**/*.json
  • plugins/yaml-schema/package.json is excluded by !**/*.json
  • plugins/zip-extractor/package.json is excluded by !**/*.json
  • support/common-utils/package.json is excluded by !**/*.json
  • turbo.json is excluded by !**/*.json
  • utils/common/package.json is excluded by !**/*.json
  • utils/extractor/package.json is excluded by !**/*.json
  • utils/fetch-schema/package.json is excluded by !**/*.json
  • utils/file-buffer/package.json is excluded by !**/*.json
  • utils/response-rejection/package.json is excluded by !**/*.json
  • utils/testing/package.json is excluded by !**/*.json
  • validate/boolean/package.json is excluded by !**/*.json
  • validate/date/package.json is excluded by !**/*.json
  • validate/email/package.json is excluded by !**/*.json
  • validate/isbn/package.json is excluded by !**/*.json
  • validate/number/package.json is excluded by !**/*.json
  • validate/phone/package.json is excluded by !**/*.json
  • validate/string/package.json is excluded by !**/*.json
📒 Files selected for processing (1)
  • bundlers/rollup-config/index.mjs (3 hunks)
🔇 Additional comments (3)
bundlers/rollup-config/index.mjs (3)

92-100: Verify type definitions compatibility.

The conditional type definitions generation needs verification to ensure it maintains compatibility with the new tsup setup.

#!/bin/bash
# Check if any packages are already using tsup for type generation
rg "tsup.*--dts" -A 2 -B 2

# Verify current type definition usage
fd "tsconfig.json" --exec jq -r 'select(.compilerOptions.declaration != null) | .compilerOptions.declaration'

108-108: Review UMD output path.

The UMD build output path has been updated to index.umd.js. While this change improves clarity, ensure it's documented in the package's README and doesn't break existing consumers.

#!/bin/bash
# Search for any references to the old UMD path
rg "index\.js.*umd" -g '!dist/*' -g '!node_modules/*' -A 2 -B 2

# Check package.json files for UMD-related exports
fd package.json --exec jq -r 'select(.exports != null) | .exports'

46-67: Verify Node.js build configuration impact.

The Node.js build configuration changes file extensions from .mjs to .js for ESM output. This could cause module resolution ambiguity as .js is traditionally associated with CommonJS.

Let's verify the impact:

✅ Verification successful

The previous results were too noisy with duplicate entries. These refined commands should give us clearer information about module resolution configuration and potential import patterns.


No module resolution ambiguity concerns with .js extension

The package correctly uses conditional exports with proper module resolution. The type: "module" field and exports configuration in package.json ensures correct resolution:

  • Node.js environment explicitly maps to dist/index.js for ESM and dist/index.cjs for CommonJS
  • Type declarations are properly mapped for both import/require scenarios
  • Only one example of direct .js import found in documentation, which follows the correct pattern
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for potential module resolution issues
# Look for import statements using these files
rg -g '!dist/*' -g '!node_modules/*' "from ['\"].*index\.js['\"]" -A 2 -B 2

# Check package.json files for module type declarations
fd package.json --exec jq -r 'select(.type != null) | "\(.name): \(.type)"'

Length of output: 26627


Script:

#!/bin/bash
# Let's check package.json for module type and exports configuration
fd package.json --exec jq -r '. | {type, exports}'

# Check for any direct imports of .js files in the source
rg -g '!dist/*' -g '!node_modules/*' "from ['\"].*\.js['\"]"

# Check for any conditional exports or module resolution configurations
fd package.json --exec jq -r '.exports | select(. != null)'

Length of output: 57335

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (1)
bundlers/tsup-config/index.js (1)

29-52: Consider additional configuration options and optimizations.

The configuration setup is solid but could benefit from more flexibility and optimization hints.

Consider these architectural improvements:

  1. Allow customization of build options:
-  const createConfig = (platform) => ({
+  const createConfig = (platform, options = {}) => ({
     name: platform,
     platform,
     minify,
-    entryPoints: ['src/index.ts'],
+    entryPoints: options.entryPoints ?? ['src/index.ts'],
     format: ['cjs', 'esm'],
     dts: true,
     outDir: 'dist',
     clean: true,
     sourcemap: true,
     treeshake: true,
     splitting: true,
+    external: options.external ?? [],
+    noExternal: options.noExternal ?? [],
+    target: options.target ?? 'node14',
     outExtension: getOutExtension(platform),
   })
  1. Add performance optimization hints:
// Add to the configuration object
esbuildOptions: (options) => {
  options.legalComments = 'none'
  options.drop = ['console', 'debugger']
  return options
}
  1. Consider adding bundle analysis in development:
if (!isProduction) {
  // Add to the configuration object
  analyze: true,
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 75df9cb and ff63707.

⛔ Files ignored due to path filters (2)
  • bundlers/rollup-config/package.json is excluded by !**/*.json
  • bundlers/tsup-config/package.json is excluded by !**/*.json
📒 Files selected for processing (2)
  • bundlers/rollup-config/index.js (3 hunks)
  • bundlers/tsup-config/index.js (1 hunks)
🔇 Additional comments (6)
bundlers/tsup-config/index.js (1)

1-52: Verify that the configuration addresses all PR objectives.

The implementation looks good and addresses the core objectives. Let's verify the configuration works as expected with the package.json exports field.

bundlers/rollup-config/index.js (5)

37-42: LGTM: Function signature changes provide better build control.

The new parameters includeNode and includeDefinitions offer granular control over build outputs, aligning with the PR's goal of improving build configuration.


81-81: LGTM: Browser build output path follows consistent naming.

The browser ESM output path now follows a consistent naming convention with the .browser.js suffix.


108-108: LGTM: UMD build output path follows consistent naming.

The UMD output path now follows a consistent naming convention with the .umd.js suffix.


92-100: Verify type definitions quality with @arethetypeswrong/cli.

The TypeScript definitions configuration looks good. Since the PR mentions integrating @arethetypeswrong/cli, ensure it's used to validate the generated type definitions.

#!/bin/bash
# Description: Check if type definitions are properly generated and valid
# Expected: Type definitions should exist and pass validation

# Test: Check if the type definitions file exists after build
if [ -f "dist/index.d.ts" ]; then
    echo "Type definitions file exists"
    # Note: Actual validation would be done by @arethetypeswrong/cli in the build pipeline
fi

46-67: Verify package.json exports field compatibility with new file paths.

The Node.js build output paths have been updated to follow modern conventions:

  • CommonJS: dist/index.cjs
  • ESM: dist/index.js

Please ensure these changes are reflected in the package.json exports field to maintain proper module resolution.

Comment on lines +6 to +10
export function defineConfig({ includeBrowser = true, includeNode = true }) {
const minify = process.env.NODE_ENV === 'production'
if (!minify) {
console.log('Not in production mode - skipping minification')
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance logging and minification configuration.

The current implementation could benefit from more explicit minification control and better logging practices.

Consider these improvements:

 export function defineConfig({ includeBrowser = true, includeNode = true }) {
-  const minify = process.env.NODE_ENV === 'production'
-  if (!minify) {
-    console.log('Not in production mode - skipping minification')
+  const isProduction = process.env.NODE_ENV === 'production'
+  const minify = process.env.MINIFY === 'true' || isProduction
+  if (!isProduction) {
+    console.debug('[tsup] Development mode - minification:', minify ? 'enabled' : 'disabled')
   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export function defineConfig({ includeBrowser = true, includeNode = true }) {
const minify = process.env.NODE_ENV === 'production'
if (!minify) {
console.log('Not in production mode - skipping minification')
}
export function defineConfig({ includeBrowser = true, includeNode = true }) {
const isProduction = process.env.NODE_ENV === 'production'
const minify = process.env.MINIFY === 'true' || isProduction
if (!isProduction) {
console.debug('[tsup] Development mode - minification:', minify ? 'enabled' : 'disabled')
}

Comment on lines 12 to 28
const EXTENSION_MAP = {
browser: {
cjs: '.browser.cjs',
esm: '.browser.js',
},
node: {
cjs: '.cjs',
esm: '.js',
},
}

const getOutExtension =
(platform) =>
({ format }) => ({
js: EXTENSION_MAP[platform][format],
})

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance extension mapping robustness.

The extension mapping implementation could be more robust and immutable.

Consider these improvements:

-  const EXTENSION_MAP = {
+  const EXTENSION_MAP = Object.freeze({
     browser: {
       cjs: '.browser.cjs',
       esm: '.browser.js',
     },
     node: {
       cjs: '.cjs',
       esm: '.js',
     },
-  }
+  })

   const getOutExtension =
     (platform) =>
     ({ format }) => ({
-      js: EXTENSION_MAP[platform][format],
+      js: EXTENSION_MAP[platform]?.[format] ?? 
+          throw new Error(`Invalid platform (${platform}) or format (${format})`)
     })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const EXTENSION_MAP = {
browser: {
cjs: '.browser.cjs',
esm: '.browser.js',
},
node: {
cjs: '.cjs',
esm: '.js',
},
}
const getOutExtension =
(platform) =>
({ format }) => ({
js: EXTENSION_MAP[platform][format],
})
const EXTENSION_MAP = Object.freeze({
browser: {
cjs: '.browser.cjs',
esm: '.browser.js',
},
node: {
cjs: '.cjs',
esm: '.js',
},
})
const getOutExtension =
(platform) =>
({ format }) => ({
js: EXTENSION_MAP[platform]?.[format] ??
throw new Error(`Invalid platform (${platform}) or format (${format})`)
})

Comment on lines +1 to +4
import dotenv from 'dotenv'
import { defineConfig as tsupDefineConfig } from 'tsup'

dotenv.config()
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Improve dotenv initialization with proper error handling and environment checks.

The current dotenv initialization could lead to runtime issues and potential security concerns.

Apply this diff to add proper error handling and environment checks:

 import dotenv from 'dotenv'
 import { defineConfig as tsupDefineConfig } from 'tsup'

-dotenv.config()
+if (process.env.NODE_ENV !== 'production') {
+  const result = dotenv.config()
+  if (result.error) {
+    console.warn('Warning: .env file not found, using default environment variables')
+  }
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import dotenv from 'dotenv'
import { defineConfig as tsupDefineConfig } from 'tsup'
dotenv.config()
import dotenv from 'dotenv'
import { defineConfig as tsupDefineConfig } from 'tsup'
if (process.env.NODE_ENV !== 'production') {
const result = dotenv.config()
if (result.error) {
console.warn('Warning: .env file not found, using default environment variables')
}
}

@carlbrugger carlbrugger deleted the feat/tsup branch October 25, 2024 15:09
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.

1 participant