nuxt-bun-compile 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,13 @@
1
+ import * as _nuxt_schema from '@nuxt/schema';
2
+
3
+ interface ModuleOptions {
4
+ enabled: boolean;
5
+ outfile: string;
6
+ extraExternals: (string | RegExp)[];
7
+ autoCompile: boolean;
8
+ bunPath?: string;
9
+ }
10
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
11
+
12
+ export { _default as default };
13
+ export type { ModuleOptions };
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "nuxt-bun-compile",
3
+ "configKey": "bunCompile",
4
+ "version": "0.1.3",
5
+ "builder": {
6
+ "@nuxt/module-builder": "1.0.2",
7
+ "unbuild": "3.6.1"
8
+ }
9
+ }
@@ -1,19 +1,9 @@
1
- import { defineNuxtModule, useLogger } from "@nuxt/kit";
2
- import type { Nuxt } from "@nuxt/schema";
3
- import type { NitroConfig } from "nitropack/types";
4
- import { execSync } from "node:child_process";
5
- import { statSync } from "node:fs";
6
- import { join } from "node:path";
1
+ import { defineNuxtModule, useLogger } from '@nuxt/kit';
2
+ import { execSync } from 'node:child_process';
3
+ import { statSync } from 'node:fs';
4
+ import { join } from 'node:path';
7
5
 
8
- export interface ModuleOptions {
9
- enabled: boolean;
10
- outfile: string;
11
- extraExternals: (string | RegExp)[];
12
- autoCompile: boolean;
13
- bunPath?: string;
14
- }
15
-
16
- const DEFAULT_EXTERNALS: (string | RegExp)[] = [
6
+ const DEFAULT_EXTERNALS = [
17
7
  "sharp",
18
8
  /^@img\//,
19
9
  "css-tree",
@@ -22,64 +12,51 @@ const DEFAULT_EXTERNALS: (string | RegExp)[] = [
22
12
  /^csso\//,
23
13
  "svgo",
24
14
  "mdn-data",
25
- /^mdn-data\//,
15
+ /^mdn-data\//
26
16
  ];
27
-
28
- export default defineNuxtModule<ModuleOptions>({
17
+ const module$1 = defineNuxtModule({
29
18
  meta: {
30
19
  name: "nuxt-bun-compile",
31
- configKey: "bunCompile",
20
+ configKey: "bunCompile"
32
21
  },
33
22
  defaults: {
34
23
  enabled: true,
35
24
  outfile: "nuxtbin",
36
25
  extraExternals: [],
37
- autoCompile: true,
26
+ autoCompile: true
38
27
  },
39
- setup(options: ModuleOptions, nuxt: Nuxt) {
28
+ setup(options, nuxt) {
40
29
  if (!options.enabled) return;
41
-
42
30
  const logger = useLogger("nuxt-bun-compile");
43
-
44
- // Configure Nitro for bun compile
45
- nuxt.hook("nitro:config" as any, (nitroConfig: NitroConfig) => {
31
+ nuxt.hook("nitro:config", (nitroConfig) => {
46
32
  logger.info("Configuring Nitro for bun --compile build");
47
-
48
33
  nitroConfig.preset = "bun";
49
34
  nitroConfig.noExternals = true;
50
35
  nitroConfig.inlineDynamicImports = true;
51
36
  nitroConfig.serveStatic = "inline";
52
-
53
37
  nitroConfig.esbuild = nitroConfig.esbuild || {};
54
38
  nitroConfig.esbuild.options = nitroConfig.esbuild.options || {};
55
39
  nitroConfig.esbuild.options.target = "esnext";
56
-
57
40
  const allExternals = [...DEFAULT_EXTERNALS, ...options.extraExternals];
58
-
59
41
  nitroConfig.rollupConfig = nitroConfig.rollupConfig || {};
60
42
  const existing = nitroConfig.rollupConfig.external;
61
43
  if (Array.isArray(existing)) {
62
44
  nitroConfig.rollupConfig.external = [...existing, ...allExternals];
63
45
  } else if (existing) {
64
- nitroConfig.rollupConfig.external = [existing as string | RegExp, ...allExternals];
46
+ nitroConfig.rollupConfig.external = [existing, ...allExternals];
65
47
  } else {
66
48
  nitroConfig.rollupConfig.external = allExternals;
67
49
  }
68
-
69
- // Auto-compile after Nitro build completes
70
50
  if (options.autoCompile) {
71
51
  nitroConfig.hooks = nitroConfig.hooks || {};
72
52
  nitroConfig.hooks.compiled = () => {
73
- const isBun = typeof (globalThis as any).Bun !== "undefined"
74
- || process.versions.bun !== undefined;
75
-
53
+ const isBun = typeof globalThis.Bun !== "undefined" || process.versions.bun !== void 0;
76
54
  if (!isBun) {
77
55
  logger.warn("Bun runtime not detected, skipping --compile step. Run with bun to enable.");
78
56
  logger.info("Try running: bun run -b build");
79
57
  logger.info("Read more: https://github.com/jprando/nuxt-bun-compile?tab=readme-ov-file#why-is--b-required");
80
58
  return;
81
59
  }
82
-
83
60
  const outputPath = ".output/server/index.mjs";
84
61
  let bunExecutable = "bun";
85
62
  if (options.bunPath) {
@@ -90,14 +67,12 @@ export default defineNuxtModule<ModuleOptions>({
90
67
  } else {
91
68
  bunExecutable = options.bunPath;
92
69
  }
93
- } catch (error) {
70
+ } catch {
94
71
  logger.warn(`Could not stat bunPath "${options.bunPath}", assuming it's a direct path.`);
95
72
  bunExecutable = options.bunPath;
96
73
  }
97
74
  }
98
-
99
75
  const cmd = `${bunExecutable} build ${outputPath} --compile --outfile ${options.outfile}`;
100
-
101
76
  logger.info(`Bun v${process.versions.bun} detected, running --compile step`);
102
77
  logger.info(`Compiling binary: ${cmd}`);
103
78
  try {
@@ -109,5 +84,7 @@ export default defineNuxtModule<ModuleOptions>({
109
84
  };
110
85
  }
111
86
  });
112
- },
87
+ }
113
88
  });
89
+
90
+ export { module$1 as default };
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "../../../.nuxt/tsconfig.server.json",
3
+ }
@@ -0,0 +1,8 @@
1
+ declare global {
2
+ namespace globalThis {
3
+ // eslint-disable-next-line no-var
4
+ var Bun: typeof import('bun') | undefined
5
+ }
6
+ }
7
+
8
+ export {}
@@ -0,0 +1,3 @@
1
+ export { default } from './module.mjs'
2
+
3
+ export { type ModuleOptions } from './module.mjs'
package/package.json CHANGED
@@ -1,25 +1,65 @@
1
1
  {
2
2
  "name": "nuxt-bun-compile",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
+ "description": "Nuxt module that automatically configures Nitro for `bun build --compile`, generating a standalone executable binary from your Nuxt app.",
5
+ "repository": "jprando/nuxt-bun-compile",
6
+ "license": "MIT",
4
7
  "type": "module",
5
- "main": "./src/module.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/types.d.mts",
11
+ "import": "./dist/module.mjs"
12
+ }
13
+ },
14
+ "main": "./dist/module.mjs",
15
+ "typesVersions": {
16
+ "*": {
17
+ ".": [
18
+ "./dist/types.d.mts"
19
+ ]
20
+ }
21
+ },
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "workspaces": [
26
+ "playground"
27
+ ],
6
28
  "scripts": {
7
- "format": "dprint fmt package.json tsconfig.json dprint.json ./src/**/*.ts"
29
+ "prepack": "nuxt-module-build build",
30
+ "dev": "npm run dev:prepare && nuxt dev playground",
31
+ "dev:build": "nuxt build playground",
32
+ "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare playground",
33
+ "release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
34
+ "lint": "eslint .",
35
+ "test": "vitest run",
36
+ "test:watch": "vitest watch",
37
+ "test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
38
+ "format": "dprint fmt package.json tsconfig.json dprint.json ./src/*.ts ./src/**/*.ts",
39
+ "prepare": "husky"
8
40
  },
9
41
  "dependencies": {
10
- "@nuxt/kit": "^3.21.1",
11
- "@nuxt/schema": "^4.3.1"
42
+ "@nuxt/kit": "^4.3.1"
12
43
  },
13
44
  "devDependencies": {
14
- "@types/node": "^25.2.3",
45
+ "@nuxt/devtools": "^3.1.1",
46
+ "@nuxt/eslint-config": "^1.14.0",
47
+ "@nuxt/module-builder": "^1.0.2",
48
+ "@nuxt/schema": "^4.3.1",
49
+ "@nuxt/test-utils": "^4.0.0",
50
+ "@types/bun": "^1.3.9",
51
+ "@types/node": "latest",
52
+ "changelogen": "^0.6.2",
15
53
  "dprint": "^0.51.1",
16
- "nitropack": "^2.13.1"
54
+ "eslint": "^10.0.0",
55
+ "husky": "^9.1.7",
56
+ "nuxt": "^4.3.1",
57
+ "typescript": "~5.9.3",
58
+ "vitest": "^4.0.18",
59
+ "vue-tsc": "^3.2.4"
17
60
  },
18
61
  "packageManager": "bun@1.3.9",
19
62
  "engines": {
20
- "node": "^24.13.1",
21
- "npm": "^11.10.0",
22
- "pnpm": "^10.29.3",
23
63
  "bun": "^1.3.9"
24
64
  },
25
65
  "trustedDependencies": [
@@ -1,23 +0,0 @@
1
- # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
- # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
-
4
- name: Node.js Package
5
-
6
- on:
7
- release:
8
- types: [created]
9
-
10
- jobs:
11
- build:
12
- runs-on: ubuntu-latest
13
- steps:
14
- - uses: actions/checkout@v4
15
- - uses: oven-sh/setup-bun@v2
16
- with:
17
- registries: https://registry.npmjs.org
18
- - run: bun i --frozen-lockfile
19
- - uses: actions/setup-node@v4
20
- with:
21
- node-version: 24
22
- registry-url: https://registry.npmjs.org/
23
- - run: npm publish
@@ -1,14 +0,0 @@
1
- {
2
- "recommendations": [
3
- "dprint.dprint",
4
- "nuxtr.nuxtr-vscode",
5
- "usernamehw.errorlens",
6
- "oderwat.indent-rainbow",
7
- "ms-vscode.vscode-typescript-next",
8
- "davidanson.vscode-markdownlint",
9
- "pkief.material-icon-theme",
10
- "yoavbls.pretty-ts-errors",
11
- "pflannery.vscode-versionlens",
12
- "fab1o.dark-plus-with-italics"
13
- ]
14
- }
@@ -1,15 +0,0 @@
1
- {
2
- "dprint.path": "./node_modules/.bin/dprint",
3
- "editor.formatOnSave": true,
4
- "editor.formatOnSaveMode": "modificationsIfAvailable",
5
- "files.trimTrailingWhitespace": true,
6
- "explorer.fileNesting.enabled": true,
7
- "editor.defaultFormatter": "dprint.dprint",
8
- "editor.gotoLocation.multipleDefinitions": "goto",
9
- "editor.gotoLocation.multipleTypeDefinitions": "goto",
10
- "editor.rulers": [
11
- 80,
12
- 100,
13
- 120
14
- ]
15
- }
package/dprint.json DELETED
@@ -1,34 +0,0 @@
1
- {
2
- "typescript": {
3
- },
4
- "json": {
5
- },
6
- "markdown": {
7
- },
8
- "toml": {
9
- },
10
- "dockerfile": {
11
- },
12
- "malva": {
13
- },
14
- "markup": {
15
- },
16
- "yaml": {
17
- },
18
- "excludes": [
19
- "**/node_modules",
20
- "**/.claude",
21
- "**/*-lock.json",
22
- "**/bun.lock"
23
- ],
24
- "plugins": [
25
- "https://plugins.dprint.dev/typescript-0.95.15.wasm",
26
- "https://plugins.dprint.dev/json-0.21.1.wasm",
27
- "https://plugins.dprint.dev/markdown-0.21.1.wasm",
28
- "https://plugins.dprint.dev/toml-0.7.0.wasm",
29
- "https://plugins.dprint.dev/dockerfile-0.3.3.wasm",
30
- "https://plugins.dprint.dev/g-plane/malva-v0.15.2.wasm",
31
- "https://plugins.dprint.dev/g-plane/markup_fmt-v0.26.0.wasm",
32
- "https://plugins.dprint.dev/g-plane/pretty_yaml-v0.6.0.wasm"
33
- ]
34
- }
package/tsconfig.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
5
- "moduleResolution": "bundler",
6
- "strict": true,
7
- "esModuleInterop": true,
8
- "skipLibCheck": true
9
- },
10
- "include": ["src"]
11
- }