Skip to content

Commit 38b3eec

Browse files
authored
migrate build scripts to esmodules (#17071)
* chore: migrate build scripts to esmodules * chore: do not use export default in build script
1 parent f6fc78f commit 38b3eec

File tree

6 files changed

+16
-9
lines changed

6 files changed

+16
-9
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"private": true,
2424
"scripts": {
2525
"compile-config": "cd packages/backend && pnpm compile-config",
26-
"build-pre": "node ./scripts/build-pre.js",
26+
"build-pre": "node scripts/build-pre.mjs",
2727
"build-assets": "node ./scripts/build-assets.mjs",
2828
"build": "pnpm build-pre && pnpm -r build && pnpm build-assets",
2929
"build-storybook": "pnpm --filter frontend build-storybook",
@@ -48,8 +48,8 @@
4848
"jest-and-coverage": "cd packages/backend && pnpm jest-and-coverage",
4949
"test": "pnpm -r test",
5050
"test-and-coverage": "pnpm -r test-and-coverage",
51-
"clean": "node ./scripts/clean.js",
52-
"clean-all": "node ./scripts/clean-all.js",
51+
"clean": "node scripts/clean.mjs",
52+
"clean-all": "node scripts/clean-all.mjs",
5353
"cleanall": "pnpm clean-all"
5454
},
5555
"resolutions": {

scripts/build-assets.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as fs from 'node:fs/promises';
77
import * as path from 'node:path';
88
import { fileURLToPath } from 'node:url';
99
import * as yaml from 'js-yaml';
10-
import buildTarball from './tarball.mjs';
10+
import { buildTarball } from './tarball.mjs';
1111

1212
const configDir = fileURLToPath(new URL('../.config', import.meta.url));
1313
const configPath = process.env.MISSKEY_CONFIG_YML
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
* SPDX-License-Identifier: AGPL-3.0-only
44
*/
55

6-
const fs = require('fs');
6+
import * as fs from 'node:fs';
7+
8+
const __dirname = import.meta.dirname;
9+
710
const packageJsonPath = __dirname + '/../package.json'
811

912
function build() {
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
* SPDX-License-Identifier: AGPL-3.0-only
44
*/
55

6-
const { execSync } = require('child_process');
7-
const fs = require('fs');
6+
import { execSync } from 'note:child_process';
7+
import * as fs from 'note:fs';
8+
9+
const __dirname = import.meta.dirname;
810

911
(async () => {
1012
fs.rmSync(__dirname + '/../packages/backend/built', { recursive: true, force: true });

scripts/clean.js renamed to scripts/clean.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
* SPDX-License-Identifier: AGPL-3.0-only
44
*/
55

6-
const fs = require('fs');
6+
import * as fs from 'note:fs';
7+
8+
const __dirname = import.meta.dirname;
79

810
(async () => {
911
fs.rmSync(__dirname + '/../packages/backend/built', { recursive: true, force: true });

scripts/tarball.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const ignore = [
1919
// Exclude files you don't want to include in the tarball here
2020
];
2121

22-
export default async function build() {
22+
export async function buildTarball() {
2323
const mkdirPromise = mkdir(resolve(cwd, 'built', 'tarball'), { recursive: true });
2424
const pack = new Pack({ cwd, gzip: true });
2525
const patterns = await walk({ path: cwd, ignoreFiles: ['.gitignore'] });

0 commit comments

Comments
 (0)