Skip to content

Commit

Permalink
Feat/bundlers (#682)
Browse files Browse the repository at this point in the history
* tsup vs rollup

* just tsup

* new plugins -> tsup

* fix turbo.json

* Fix package.json

* jest.config.js --> jest.config.cjs

* add UMD support & remove parcel deps

* Remove dup type

* revert changelog update

* Create five-hounds-wash.md

* add publint

* package.json updates

* add umd build

* add sourcemaps & treeshaking

* Update index.mjs

* remove publint deps

* add tsup config to missed packages

* Fix main

* Fix dup devDep

* cleanup
  • Loading branch information
carlbrugger authored Oct 29, 2024
1 parent 771314e commit 3b9eedd
Show file tree
Hide file tree
Showing 217 changed files with 8,390 additions and 11,583 deletions.
61 changes: 61 additions & 0 deletions .changeset/five-hounds-wash.md
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.
2 changes: 1 addition & 1 deletion bundlers/rollup-config/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @flatfile/rollup-config
# @flatfile/bundler-config-rollup

## 0.1.1

Expand Down
60 changes: 35 additions & 25 deletions bundlers/rollup-config/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
? [
Expand All @@ -72,7 +78,7 @@ export function buildConfig({
},
{
exports: 'auto',
file: 'dist/index.browser.mjs',
file: 'dist/index.browser.js',
sourcemap: false,
format: 'es',
},
Expand All @@ -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,
},
Expand Down
2 changes: 1 addition & 1 deletion bundlers/rollup-config/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@flatfile/rollup-config",
"name": "@flatfile/bundler-config-rollup",
"version": "0.1.1",
"description": "",
"private": true,
Expand Down
51 changes: 51 additions & 0 deletions bundlers/tsup-config/index.mjs
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()

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 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,
})

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),
})

const nodeConfig = createConfig('node')
const browserConfig = createConfig('browser')

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

return tsupDefineConfig(configs)
}
13 changes: 13 additions & 0 deletions bundlers/tsup-config/package.json
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"
}
}
File renamed without changes.
57 changes: 36 additions & 21 deletions convert/currency/package.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,50 @@
{
"name": "@flatfile/plugin-convert-currency",
"version": "0.1.0",
"url": "https://github.com/FlatFilers/flatfile-plugins/tree/main/convert/currency",
"description": "A Flatfile plugin for currency conversion using Open Exchange Rates API",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"browser": {
"./dist/index.cjs": "./dist/index.browser.cjs",
"./dist/index.mjs": "./dist/index.browser.mjs"
"registryMetadata": {
"category": "convert"
},
"type": "module",
"engines": {
"node": ">= 16"
},
"exports": {
"types": "./dist/index.d.ts",
"node": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
".": {
"node": {
"types": {
"import": "./dist/index.d.ts",
"require": "./dist/index.d.cts"
},
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"browser": {
"types": {
"import": "./dist/index.d.ts",
"require": "./dist/index.d.cts"
},
"import": "./dist/index.browser.js",
"require": "./dist/index.browser.cjs"
},
"default": "./dist/index.js"
},
"browser": {
"require": "./dist/index.browser.cjs",
"import": "./dist/index.browser.mjs"
},
"default": "./dist/index.mjs"
"./package.json": "./package.json"
},
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"source": "./src/index.ts",
"types": "./dist/index.d.ts",
"files": [
"dist/**"
],
"scripts": {
"build": "rollup -c",
"build:watch": "rollup -c --watch",
"build:prod": "NODE_ENV=production rollup -c",
"check": "tsc ./**/*.ts --noEmit --esModuleInterop",
"build": "tsup",
"build:watch": "tsup --watch",
"build:prod": "NODE_ENV=production tsup",
"checks": "tsc --noEmit && attw --pack . && publint .",
"lint": "tsc --noEmit",
"test": "jest src/*.spec.ts --detectOpenHandles",
"test:unit": "jest src/*.spec.ts --testPathIgnorePatterns=.*\\.e2e\\.spec\\.ts$ --detectOpenHandles",
"test:e2e": "jest src/*.e2e.spec.ts --detectOpenHandles"
Expand All @@ -49,11 +64,11 @@
"@flatfile/listener": "^1.0.1"
},
"devDependencies": {
"@flatfile/rollup-config": "^0.1.1"
"@flatfile/bundler-config-tsup": "^0.0.0"
},
"repository": {
"type": "git",
"url": "https://github.com/FlatFilers/flatfile-plugins.git",
"url": "git+https://github.com/FlatFilers/flatfile-plugins.git",
"directory": "convert/currency"
},
"browserslist": [
Expand Down
5 changes: 0 additions & 5 deletions convert/currency/rollup.config.mjs

This file was deleted.

3 changes: 3 additions & 0 deletions convert/currency/tsup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { defineConfig } from '@flatfile/bundler-config-tsup'

export default defineConfig({})
File renamed without changes.
Loading

0 comments on commit 3b9eedd

Please sign in to comment.