Skip to content

Commit aa72526

Browse files
committed
fix: fix eslint and postinstall for modules
1 parent 395019e commit aa72526

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

eslint.config.js renamed to eslint.config.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ module.exports = [
6363
},
6464
},
6565
{
66-
files: ['scripts/**/*.js'],
66+
files: ['scripts/**/*.js', 'scripts/**/*.cjs'],
6767
languageOptions: {
6868
ecmaVersion: 'latest',
6969
sourceType: 'commonjs',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"lint": "cargo clippy && pnpm eslint",
3737
"postbuild:rust-debug": "neon dist < cargo.log",
3838
"postcross-build": "neon dist -m /target < cross.log",
39-
"postinstall": "node scripts/postinstall.js",
39+
"postinstall": "node scripts/postinstall.cjs",
4040
"release": "run-s build changeset:publish",
4141
"test": "pnpm build:debug && vitest run",
4242
"test:watch": "pnpm build:debug && vitest",
Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@
77
* it.
88
*/
99

10-
import { stat, readFile } from 'node:fs/promises';
11-
import { createWriteStream } from 'node:fs';
12-
import { PassThrough } from 'node:stream';
13-
import cliProgress from 'cli-progress';
14-
import unzipper from 'unzipper';
15-
import os from 'node:os';
16-
import { mkdirp } from 'mkdirp';
17-
import { resolve } from 'node:path';
18-
import { exec } from 'node:child_process';
19-
import { promisify } from 'node:util';
20-
import fetch from 'node-fetch';
21-
import prettyBytes from 'pretty-bytes';
22-
import { packageDirectory } from 'pkg-dir';
10+
const { stat, readFile } = require('node:fs/promises');
11+
const { createWriteStream } = require('node:fs');
12+
const { PassThrough } = require('node:stream');
13+
const cliProgress = require('cli-progress');
14+
const unzipper = require('unzipper');
15+
const os = require('node:os');
16+
const { mkdirp } = require('mkdirp');
17+
const { resolve } = require('node:path');
18+
const { exec } = require('node:child_process');
19+
const { promisify } = require('node:util');
20+
// node-fetch v3 is ES module only, so we'll import it dynamically
21+
// pretty-bytes is ES module only, so we'll import it dynamically
22+
// pkg-dir is ES module only, so we'll import it dynamically
2323

2424
const pExec = promisify(exec);
2525

@@ -72,6 +72,8 @@ function getPlatform() {
7272

7373
async function downloadFromUrl(appRoot, url) {
7474
console.log(`Checking for a release at: ${url}`);
75+
const { default: fetch } = await import('node-fetch');
76+
const { default: prettyBytes } = await import('pretty-bytes');
7577
const res = await fetch(url);
7678

7779
if (res.ok) {
@@ -171,7 +173,8 @@ async function buildRust(root) {
171173
}
172174

173175
async function main() {
174-
const appRoot = await packageDirectory(import.meta.url);
176+
const { packageDirectory } = await import('pkg-dir');
177+
const appRoot = await packageDirectory(__filename);
175178
const distRoot = resolve(appRoot, 'dist');
176179
const cargoDistPath = resolve(distRoot, 'Cargo.toml');
177180
const libraryOverridePath = process.env.C2PA_LIBRARY_PATH;

0 commit comments

Comments
 (0)