Skip to content

Commit 1fb4274

Browse files
authored
fix: replace import assertion with readFileSync in rollup configs (#1052)
* fix: replace import assertion with readFileSync in rollup configs - Replace 'import packageJson from ./package.json assert { type: 'json' }' with readFileSync - Fixes build error: SyntaxError: Unexpected identifier 'assert' - Affects packages/auth and packages/api rollup.config.js files - Uses Node.js fs.readFileSync which is compatible with Rollup parser * fix: use 'with' syntax for JSON import assertions in rollup configs - Replace readFileSync with 'with { type: 'json' }' import syntax - Uses newer standard import attributes syntax * fix: use createRequire with explicit path resolution for Node 16 compatibility - Replace 'with { type: 'json' }' import syntax with createRequire approach - Add fileURLToPath and path.dirname for explicit path resolution - Ensures backward compatibility with Node.js 16.19.0 - Fixes build error during yarn install postinstall script - Affects packages/auth and packages/api rollup.config.js files
1 parent 4c3cfd1 commit 1fb4274

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

packages/api/rollup.config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import dts from 'rollup-plugin-dts'
22
import esbuild from 'rollup-plugin-esbuild'
3-
import packageJson from './package.json' assert { type: 'json' };
43
import path from 'path';
4+
import { createRequire } from 'module';
5+
import { fileURLToPath } from 'url';
6+
7+
const __filename = fileURLToPath(import.meta.url);
8+
const __dirname = path.dirname(__filename);
9+
const require = createRequire(import.meta.url);
10+
const packageJson = require(path.resolve(__dirname, './package.json'));
511

612
const name = packageJson.main.replace(/\.js$/, '');
713

packages/auth/rollup.config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import dts from 'rollup-plugin-dts'
22
import esbuild from 'rollup-plugin-esbuild'
33
import path from 'path';
4-
import packageJson from './package.json' assert { type: 'json' };
4+
import { createRequire } from 'module';
5+
import { fileURLToPath } from 'url';
6+
7+
const __filename = fileURLToPath(import.meta.url);
8+
const __dirname = path.dirname(__filename);
9+
const require = createRequire(import.meta.url);
10+
const packageJson = require(path.resolve(__dirname, './package.json'));
511

612
const name = packageJson.main.replace(/\.js$/, '');
713

0 commit comments

Comments
 (0)