Skip to content

Commit 04c05f2

Browse files
committed
fix: use CommonJS format for Rollup config for better compatibility
- Renamed rollup.config.js to rollup.config.cjs - Removed "type": "module" from package.json - Updated build scripts to explicitly reference .cjs config file - Maintained all TypeScript improvements and unified configuration This ensures compatibility with existing Node.js environments that may not fully support ES modules while keeping the simplified build setup.
1 parent f946db0 commit 04c05f2

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,12 @@
4040
"main": "lib/index.js",
4141
"module": "lib/index.es.js",
4242
"types": "lib/index.d.ts",
43-
"type": "module",
4443
"files": [
4544
"lib",
4645
"resources"
4746
],
4847
"scripts": {
49-
"build": "rm -rf lib && rollup -c && yarn build:types",
48+
"build": "rm -rf lib && rollup -c rollup.config.cjs && yarn build:types",
5049
"build:types": "tsc --emitDeclarationOnly",
5150
"check": "biome check .",
5251
"format": "biome format --write .",
@@ -57,8 +56,8 @@
5756
"prepublishOnly": "yarn build",
5857
"release": "semantic-release",
5958
"release:dry": "semantic-release --dry-run",
60-
"test": "NODE_OPTIONS='--experimental-vm-modules' jest",
61-
"watch": "rm -rf lib && rollup -cw"
59+
"test": "jest",
60+
"watch": "rm -rf lib && rollup -cw rollup.config.cjs"
6261
},
6362
"config": {
6463
"commitizen": {

rollup.config.js renamed to rollup.config.cjs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
import { readFileSync } from 'node:fs'
2-
import commonjs from '@rollup/plugin-commonjs'
3-
import json from '@rollup/plugin-json'
4-
import resolve from '@rollup/plugin-node-resolve'
5-
import terser from '@rollup/plugin-terser'
6-
import esbuild from 'rollup-plugin-esbuild'
1+
const { readFileSync } = require('node:fs')
2+
const esbuild = require('rollup-plugin-esbuild').default
3+
const resolve = require('@rollup/plugin-node-resolve').default
4+
const commonjs = require('@rollup/plugin-commonjs')
5+
const json = require('@rollup/plugin-json')
6+
const terser = require('@rollup/plugin-terser').default
77

88
const pkg = JSON.parse(readFileSync('./package.json', 'utf-8'))
99

1010
// External dependencies for main build
11-
const external = [
12-
...Object.keys(pkg.dependencies || {}),
13-
...Object.keys(pkg.peerDependencies || {}),
14-
]
11+
const external = [...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {})]
1512

1613
// Base ESBuild config
1714
const esbuildBase = {
@@ -27,7 +24,7 @@ const esbuildBase = {
2724
}
2825

2926
// Main library config (external dependencies)
30-
export const mainConfig = {
27+
const mainConfig = {
3128
input: 'src/index.ts',
3229
output: [
3330
{
@@ -54,7 +51,7 @@ const serverlessPlugins = [
5451
esbuild(esbuildBase),
5552
]
5653

57-
export const serverlessConfig = [
54+
const serverlessConfig = [
5855
// ESM build
5956
{
6057
input: 'src/index.serverless.ts',
@@ -126,4 +123,4 @@ export const serverlessConfig = [
126123
]
127124

128125
// Export all configs
129-
export default [mainConfig, ...serverlessConfig]
126+
module.exports = [mainConfig, ...serverlessConfig]

0 commit comments

Comments
 (0)