-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesbuild.mjs
More file actions
83 lines (77 loc) · 2.16 KB
/
Copy pathesbuild.mjs
File metadata and controls
83 lines (77 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import * as esbuild from 'esbuild'
import * as fs from "node:fs";
fs.rmSync('dist', { recursive: true, force: true });
fs.mkdirSync('dist', { recursive: true });
fs.cpSync('jpostcode-data/data/json', 'dist/jpostcode-data/data/json', {recursive: true});
fs.copyFileSync('jpostcode-data/LICENSE.txt', 'dist/jpostcode-data/LICENSE.txt');
const licenseBanner = `/*!
* jpostcode-js
* Copyright (c) 2026 Matzlika Co., Ltd.
* Released under the MIT License.
*
* Includes postal code data from jpostcode-data
* (https://github.com/kufu/jpostcode-data)
* Copyright 2023 SmartHR, Inc.
* Released under the MIT License.
*/`;
await esbuild.build({
entryPoints: ["src/jpostcode.ts"],
outfile: "dist/index.cjs.js",
bundle: true,
platform: "node",
target: "esnext",
minify: true,
sourcemap: true,
format: "cjs",
banner: {
js: licenseBanner
}
}).catch((e) => {
console.log(e);
process.exit(1);
}).then(() => console.log("done cjs build"));
await esbuild.build({
entryPoints: ["src/jpostcode.ts"],
outfile: "dist/index.mjs",
bundle: true,
platform: "node",
target: "esnext",
minify: true,
sourcemap: true,
format: "esm",
banner: {
js: `${licenseBanner}\nimport path from "node:path"; import { fileURLToPath } from "node:url"; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename);`
}
}).catch((e) => {
console.log(e);
process.exit(1);
}).then(() => console.log("done esm build"));
// jpostcode/web — バンドラー/ブラウザ向けの fetch ベース版
await esbuild.build({
entryPoints: ["src/web.ts"],
outfile: "dist/web.mjs",
bundle: true,
platform: "neutral",
target: "es2018",
minify: true,
sourcemap: true,
format: "esm",
banner: { js: licenseBanner }
}).catch((e) => {
console.log(e);
process.exit(1);
}).then(() => console.log("done web esm build"));
await esbuild.build({
entryPoints: ["src/web.ts"],
outfile: "dist/web.cjs",
bundle: true,
platform: "neutral",
target: "es2018",
minify: true,
sourcemap: true,
format: "cjs",
banner: { js: licenseBanner }
}).catch((e) => {
console.log(e);
process.exit(1);
}).then(() => console.log("done web cjs build"));