Skip to content

Commit

Permalink
Fix assert Error on Build in Node 22+ (#199)
Browse files Browse the repository at this point in the history
Newer versions of node do not support importing with the `assert` syntax and instead use `with` but this breaks the build on versions of node older than 22.

To preserve compatibility with all node versions this code reads and parses the package.json file explicitly
  • Loading branch information
jeff-wood-readyup authored Dec 2, 2024
1 parent f86af9b commit efe9fc3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import nodePolyfills from 'rollup-plugin-polyfill-node';
import filesize from 'rollup-plugin-filesize';
import fs from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';

import pkg from './package.json' assert { type: 'json' };
const pkgPath = join(dirname(fileURLToPath(import.meta.url)), 'package.json');

const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));

const deps = Object.keys(pkg.dependencies);

Expand Down

0 comments on commit efe9fc3

Please sign in to comment.