import { build } from 'esbuild'
import { glsl } from 'esbuild-plugin-glsl'
+/** @import { BuildOptions } from 'esbuild' */
-await build({
+/** @type BuildOptions */
+const sharedOptions = {
bundle: true,
- platform: 'browser',
- entryPoints: [
- { in: './src/main.ts', out: 'main.min' },
- { in: './src/types.d.ts', out: 'types.d' }
- ],
+ format: 'esm',
+ outdir: 'dist',
loader: {
- '.d.ts': 'copy',
'.wasm': 'binary'
},
- format: 'esm',
legalComments: 'inline',
- outdir: 'dist',
- target: 'es2022',
dropLabels: process.env.NODE_ENV === 'development' ? [] : ['LOG'],
plugins: [
glsl({
preserveLegalComments: true
})
]
-})
+}
-await build({
- bundle: true,
+/** @type BuildOptions */
+const bundleOptions = {
+ ...sharedOptions,
+ platform: 'browser',
+ target: 'es2022',
+ entryPoints: [
+ './src/index.ts'
+ ]
+}
+
+/** @type BuildOptions */
+const cliOptions = {
+ ...sharedOptions,
platform: 'node',
+ target: 'node22',
+ outdir: 'dist/bin',
entryPoints: [
'./src/bin/cli.ts',
'./src/bin/server.ts'
],
- format: 'esm',
- legalComments: 'inline',
- outdir: 'dist/bin',
- packages: 'external',
- target: 'node22'
-})
+ packages: 'external'
+}
+
+await build(bundleOptions)
+await build(cliOptions)
"AUTHORS.md",
"package.json.license"
],
- "main": "./dist/main.min.js",
"bin": {
"nano-pow": "dist/bin/nano-pow.sh"
},
"type": "module",
"exports": {
".": {
- "types": "./dist/types.d.ts",
- "default": "./dist/main.min.js"
+ "types": "./dist/index.d.ts",
+ "default": "./dist/index.js"
}
},
- "types": "./dist/types.d.ts",
- "unpkg": "./dist/main.min.js"
+ "types": "./dist/index.d.ts"
}
//! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@codecow.com>
//! SPDX-License-Identifier: GPL-3.0-or-later
-import * as http from 'node:http'
+import { WorkErrorResponse, WorkGenerateResponse, WorkValidateResponse } from '#types'
+import { isHex32, isHex8, Logger } from '#utils'
import { Serializable } from 'node:child_process'
import { hash } from 'node:crypto'
import { readFile, writeFile } from 'node:fs/promises'
+import * as http from 'node:http'
import { homedir } from 'node:os'
import { join } from 'node:path'
import { launch } from 'puppeteer'
-import { WorkErrorResponse, WorkGenerateResponse, WorkValidateResponse } from '#types'
-import { isHex8, isHex32, Logger } from '#utils'
/**
* Used to define NanoPow server configuration.
// Initialize puppeteer
LOG: logger.log('starting work server')
-const NanoPow = await readFile(new URL('../main.min.js', import.meta.url), 'utf-8')
+const NanoPow = await readFile(new URL('../index.js', import.meta.url), 'utf-8')
LOG: logger.log('launching puppeteer browser')
const browser = await launch({
handleSIGHUP: false,
//! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@codecow.com>
//! SPDX-License-Identifier: GPL-3.0-or-later
-export { generate as NanoPowCpu } from '#lib/generate/cpu'
-export { generate as NanoPowWasm } from '#lib/generate/wasm'
-export { generate as NanoPowWebgl } from '#lib/generate/webgl'
-export { generate as NanoPowWebgpu } from '#lib/generate/webgpu'
+export { generate as NanoPowCpu } from './cpu'
+export { generate as NanoPowWasm } from './wasm'
+export { generate as NanoPowWebgl } from './webgl'
+export { generate as NanoPowWebgpu } from './webgpu'
]
},
"include": [
- "src/main.ts",
+ "src/index.ts",
"src/**/*.ts"
],
"exclude": [