-
Notifications
You must be signed in to change notification settings - Fork 12
Feat/bundlers #682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/bundlers #682
Changes from all commits
c5522c9
0083eba
fb8649f
dc63273
2d27e92
06e21d8
24262ec
294678b
cfcd829
d04c191
1cdf87c
1799bf8
de08e1b
eeebfd8
4f05aa7
44ff7b0
1355083
449301d
cec9021
2411464
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| --- | ||
| '@flatfile/plugin-webhook-event-forwarder': minor | ||
| '@flatfile/plugin-foreign-db-extractor': minor | ||
| '@flatfile/plugin-delimiter-extractor': minor | ||
| '@flatfile/plugin-convert-sql-ddl': minor | ||
| '@flatfile/plugin-connect-via-merge': minor | ||
| '@flatfile/util-response-rejection': minor | ||
| '@flatfile/plugin-export-workbook': minor | ||
| '@flatfile/plugin-space-configure': minor | ||
| '@flatfile/bundler-config-rollup': minor | ||
| '@flatfile/plugin-graphql-schema': minor | ||
| '@flatfile/plugin-json-extractor': minor | ||
| '@flatfile/plugin-convert-openapi-schema': minor | ||
| '@flatfile/plugin-webhook-egress': minor | ||
| '@flatfile/plugin-xlsx-extractor': minor | ||
| '@flatfile/plugin-dxp-configure': minor | ||
| '@flatfile/plugin-pdf-extractor': minor | ||
| '@flatfile/plugin-psv-extractor': minor | ||
| '@flatfile/plugin-tsv-extractor': minor | ||
| '@flatfile/plugin-xml-extractor': minor | ||
| '@flatfile/plugin-zip-extractor': minor | ||
| '@flatfile/bundler-config-tsup': minor | ||
| '@flatfile/common-plugin-utils': minor | ||
| '@flatfile/plugin-constraints': minor | ||
| '@flatfile/plugin-job-handler': minor | ||
| '@flatfile/plugin-convert-json-schema': minor | ||
| '@flatfile/plugin-record-hook': minor | ||
| '@flatfile/plugin-view-mapped': minor | ||
| '@flatfile/plugin-convert-yaml-schema': minor | ||
| '@flatfile/plugin-convert-what3words': minor | ||
| '@flatfile/plugin-export-pivot-table': minor | ||
| '@flatfile/plugin-extract-html-table': minor | ||
| '@flatfile/plugin-import-llm-records': minor | ||
| '@flatfile/util-fetch-schema': minor | ||
| '@flatfile/plugin-convert-translate': minor | ||
| '@flatfile/util-file-buffer': minor | ||
| '@flatfile/plugin-convert-currency': minor | ||
| '@flatfile/plugin-enrich-sentiment': minor | ||
| '@flatfile/plugin-enrich-summarize': minor | ||
| '@flatfile/plugin-extract-markdown': minor | ||
| '@flatfile/plugin-autocast': minor | ||
| '@flatfile/plugin-validate-boolean': minor | ||
| '@flatfile/plugin-automap': minor | ||
| '@flatfile/plugin-rollout': minor | ||
| '@flatfile/util-extractor': minor | ||
| '@flatfile/plugin-validate-number': minor | ||
| '@flatfile/plugin-validate-string': minor | ||
| '@flatfile/plugin-enrich-geocode': minor | ||
| '@flatfile/plugin-dedupe': minor | ||
| '@flatfile/plugin-validate-email': minor | ||
| '@flatfile/plugin-validate-phone': minor | ||
| '@flatfile/utils-testing': minor | ||
| '@flatfile/plugin-validate-date': minor | ||
| '@flatfile/plugin-validate-isbn': minor | ||
| '@flatfile/plugin-import-faker': minor | ||
| '@flatfile/util-common': minor | ||
| '@flatfile/plugin-enrich-gpx': minor | ||
| '@flatfile/plugin-import-rss': minor | ||
| --- | ||
|
|
||
| The release swaps the package's bundler to tsup. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| # @flatfile/rollup-config | ||
| # @flatfile/bundler-config-rollup | ||
|
|
||
| ## 0.1.1 | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,30 +35,36 @@ function commonPlugins(browser, umd = false) { | |
|
|
||
| export function buildConfig({ | ||
| external = [], | ||
| includeNode = true, | ||
| includeBrowser = true, | ||
| includeDefinition = true, | ||
| includeUmd = false, | ||
| umdConfig = { name: undefined, external: [] }, | ||
| }) { | ||
| return [ | ||
| // Node.js build | ||
| { | ||
| input: 'src/index.ts', | ||
| output: [ | ||
| { | ||
| exports: 'auto', | ||
| file: 'dist/index.cjs', | ||
| format: 'cjs', | ||
| }, | ||
| { | ||
| exports: 'auto', | ||
| file: 'dist/index.mjs', | ||
| sourcemap: false, | ||
| format: 'es', | ||
| }, | ||
| ], | ||
| plugins: commonPlugins(false), | ||
| external, | ||
| }, | ||
| ...(includeNode | ||
| ? [ | ||
| { | ||
| input: 'src/index.ts', | ||
| output: [ | ||
| { | ||
| exports: 'auto', | ||
| file: 'dist/index.cjs', | ||
| format: 'cjs', | ||
| }, | ||
| { | ||
| exports: 'auto', | ||
| file: 'dist/index.js', | ||
| sourcemap: false, | ||
| format: 'es', | ||
| }, | ||
| ], | ||
| plugins: commonPlugins(false), | ||
| external, | ||
| }, | ||
| ] | ||
| : []), | ||
| // Browser build | ||
| ...(includeBrowser | ||
| ? [ | ||
|
|
@@ -72,7 +78,7 @@ export function buildConfig({ | |
| }, | ||
| { | ||
| exports: 'auto', | ||
| file: 'dist/index.browser.mjs', | ||
| file: 'dist/index.browser.js', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider browser-specific optimizations. While the browser build is properly separated, consider adding browser-specific optimizations such as:
|
||
| sourcemap: false, | ||
| format: 'es', | ||
| }, | ||
|
|
@@ -83,19 +89,23 @@ export function buildConfig({ | |
| ] | ||
| : []), | ||
| // Definition file | ||
| { | ||
| input: 'src/index.ts', | ||
| output: [{ file: 'dist/index.d.ts', format: 'es' }], | ||
| plugins: [dts()], | ||
| }, | ||
| ...(includeDefinition | ||
| ? [ | ||
| { | ||
| input: 'src/index.ts', | ||
| output: [{ file: 'dist/index.d.ts', format: 'es' }], | ||
| plugins: [dts()], | ||
| }, | ||
| ] | ||
| : []), | ||
| // UMD build | ||
| ...(includeUmd | ||
| ? [ | ||
| { | ||
| input: 'src/index.ts', | ||
| output: [ | ||
| { | ||
| file: 'dist/index.js', | ||
| file: 'dist/index.umd.js', | ||
| format: 'umd', | ||
| name: umdConfig.name, | ||
| }, | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,51 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import dotenv from 'dotenv' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { defineConfig as tsupDefineConfig } from 'tsup' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dotenv.config() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+4
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider adding error handling for environment configuration. The direct call to import dotenv from 'dotenv'
import { defineConfig as tsupDefineConfig } from 'tsup'
-dotenv.config()
+try {
+ dotenv.config({ debug: process.env.DEBUG === 'true' })
+} catch (error) {
+ console.warn('Warning: Error loading .env file:', error.message)
+}📝 Committable suggestion
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') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+6
to
+10
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve environment validation and logging. The current implementation has two potential 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 nodeEnv = process.env.NODE_ENV?.toLowerCase()
+ if (!['development', 'production', 'test'].includes(nodeEnv)) {
+ console.warn(`Warning: Unexpected NODE_ENV value: ${nodeEnv}. Defaulting to development.`)
}
+ const minify = nodeEnv === 'production'📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const EXTENSION_MAP = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| browser: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cjs: '.browser.cjs', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| default: '.browser.js', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| node: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cjs: '.cjs', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| default: '.js', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const getOutExtension = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (platform) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ({ format }) => ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| js: EXTENSION_MAP[platform][format] || EXTENSION_MAP[platform].default, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+12
to
+27
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add type safety to extension mapping. The extension mapping logic could benefit from TypeScript types and validation for unknown formats. // Add these type definitions at the top of the file
type Platform = 'browser' | 'node'
type Format = 'cjs' | 'default'
type ExtensionMap = Record<Platform, Record<Format, string>>
const EXTENSION_MAP: ExtensionMap = {
// ... your existing map
}
const getOutExtension = (platform: Platform) =>
({ format }: { format: string }) => ({
js: EXTENSION_MAP[platform][format as Format] ?? EXTENSION_MAP[platform].default
}) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+28
to
+41
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Enhance configuration flexibility. The configuration could be more flexible by:
-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,
outExtension: getOutExtension(platform),
+ external: options.external ?? [],
})📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const nodeConfig = createConfig('node') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const browserConfig = createConfig('browser') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const configs = [] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (includeNode) configs.push(nodeConfig) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (includeBrowser) configs.push(browserConfig) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return tsupDefineConfig(configs) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+43
to
+51
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification 🛠️ Refactor suggestion Add validation to prevent empty configurations The suggested validation is important since the config is widely used across the project (50+ files) and an empty configuration could cause build failures. Adding the validation will provide clear error messages instead of potential downstream build errors. const configs = []
if (includeNode) configs.push(nodeConfig)
if (includeBrowser) configs.push(browserConfig)
+ if (configs.length === 0) {
+ throw new Error('At least one platform (browser or node) must be included in the configuration')
+ }
+
return tsupDefineConfig(configs)🔗 Analysis chainAdd configuration validation. The configuration application should validate that at least one platform is included to prevent empty configurations. const configs = []
if (includeNode) configs.push(nodeConfig)
if (includeBrowser) configs.push(browserConfig)
+ if (configs.length === 0) {
+ throw new Error('At least one platform (browser or node) must be included in the configuration')
+ }
+
return tsupDefineConfig(configs)🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Check if this configuration is used consistently across the project
rg -l "from ['\"]\@flatfile\/bundler-config-tsup['\"]"
Length of output: 180 Script: #!/bin/bash
# Search for imports of the tsup config package with proper escaping
rg -l "from ['\"]@flatfile/bundler-config-tsup['\"]"
# Search for direct usage of the package name
rg -l "@flatfile/bundler-config-tsup"
# Look for package.json files that might use this dependency
fd "package.json" --exec grep -l "bundler-config-tsup" {}
Length of output: 7736 Script: #!/bin/bash
# Check how the config is used in some of these files to understand if validation exists in usage
rg -A 5 "from ['\"]\@flatfile\/bundler-config-tsup['\"]" "plugins/*/tsup.config.mjs" "utils/*/tsup.config.mjs"
# Look at the implementation to see if there's any existing validation
cat bundlers/tsup-config/index.mjs
Length of output: 1477 Script: #!/bin/bash
# Let's check how this config is used in some example files with proper escaping
rg -A 5 "from '@flatfile/bundler-config-tsup'" "plugins/*/tsup.config.mjs" "utils/*/tsup.config.mjs"
# Also check if there are any existing error handling patterns in the codebase
rg "throw new Error\(" bundlers/tsup-config/
Length of output: 285 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "name": "@flatfile/bundler-config-tsup", | ||
| "version": "0.0.0", | ||
| "description": "", | ||
| "private": true, | ||
| "main": "index.mjs", | ||
| "scripts": {}, | ||
| "author": "Flatfile, Inc.", | ||
| "license": "ISC", | ||
| "dependencies": { | ||
| "tsup": "^8.3.0" | ||
| } | ||
| } |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import { defineConfig } from '@flatfile/bundler-config-tsup' | ||
|
|
||
| export default defineConfig({}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Rollup configuration should be removed as tsup migration is complete
The codebase shows clear evidence of a successful migration to tsup:
plugins/record-hook/rollup.config.mjs, which also has a corresponding tsup configurationSince the package
plugins/record-hookhas both Rollup and tsup configurations, and given the PR's objective to transition to tsup, this Rollup configuration file should be removed to maintain consistency across the codebase.🔗 Analysis chain
Verify the transition plan from Rollup to tsup.
While the parameter additions improve bundle configuration flexibility, the PR objectives indicate a transition from Rollup to tsup. Please clarify if this file will be maintained alongside tsup or if it's intended to be deprecated.
Let's verify the transition status:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 2268