rebuildjs 0.10.1 → 0.10.2
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.
- package/build/index.d.ts +1 -1
- package/build/index.js +40 -34
- package/package.json +1 -1
package/build/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BuildOptions, Plugin } from 'esbuild'
|
|
2
|
+
export declare function browser__build(config?:rebuildjs__build_config_T):Promise<void>
|
|
2
3
|
export declare function server__build(config?:rebuildjs__build_config_T):Promise<void>
|
|
3
4
|
export declare function server__external_(config?:Partial<BuildOptions>):Promise<string[]>
|
|
4
|
-
export declare function browser__build(config?:rebuildjs__build_config_T):Promise<void>
|
|
5
5
|
export declare function rebuildjs__plugin_():Plugin
|
|
6
6
|
export type rebuildjs__build_config_T = Partial<BuildOptions>&{ rebuildjs?: rebuildjs__plugin_config_T }
|
|
7
7
|
export type rebuildjs__plugin_config_T = {
|
package/build/index.js
CHANGED
|
@@ -17,14 +17,19 @@ import {
|
|
|
17
17
|
server__metafile__set
|
|
18
18
|
} from '../server/index.js'
|
|
19
19
|
/**
|
|
20
|
-
* @param {
|
|
20
|
+
* @param {Plugin}config
|
|
21
21
|
* @returns {Promise<void>}
|
|
22
|
+
* @private
|
|
22
23
|
*/
|
|
23
|
-
export async function
|
|
24
|
-
const {
|
|
25
|
-
|
|
24
|
+
export async function browser__build(config) {
|
|
25
|
+
const {
|
|
26
|
+
rebuildjs,
|
|
27
|
+
...esbuild__config
|
|
28
|
+
} = config ?? {}
|
|
29
|
+
await rm(browser_path_(app_ctx), { recursive: true, force: true })
|
|
30
|
+
await mkdir(browser_path_(app_ctx), { recursive: true })
|
|
26
31
|
const path_a = await new fdir()
|
|
27
|
-
.glob('**/*.
|
|
32
|
+
.glob('**/*.browser.{ts,js,tsx,jsx}')
|
|
28
33
|
.withFullPaths()
|
|
29
34
|
.crawl(app_path_(app_ctx))
|
|
30
35
|
.withPromise()
|
|
@@ -34,10 +39,12 @@ export async function server__build(config) {
|
|
|
34
39
|
entryPoints.push(path)
|
|
35
40
|
}
|
|
36
41
|
const plugins = [rebuildjs__plugin_(), ...(esbuild__config.plugins || [])]
|
|
42
|
+
/** @type {BuildOptions} */
|
|
37
43
|
const esbuild_config = {
|
|
38
44
|
entryNames: '[name]-[hash]',
|
|
39
45
|
assetNames: '[name]-[hash]',
|
|
40
46
|
bundle: true,
|
|
47
|
+
external: [],
|
|
41
48
|
target: 'es2020',
|
|
42
49
|
treeShaking: true,
|
|
43
50
|
minify: is_prod_(app_ctx),
|
|
@@ -45,39 +52,33 @@ export async function server__build(config) {
|
|
|
45
52
|
...esbuild__config,
|
|
46
53
|
entryPoints,
|
|
47
54
|
format: 'esm',
|
|
48
|
-
platform: '
|
|
55
|
+
platform: 'browser',
|
|
49
56
|
absWorkingDir: cwd_(app_ctx),
|
|
50
57
|
metafile: true,
|
|
51
|
-
outdir:
|
|
52
|
-
external: server__external_(esbuild__config),
|
|
58
|
+
outdir: browser_path_(app_ctx),
|
|
53
59
|
plugins,
|
|
54
60
|
}
|
|
55
|
-
if (rebuildjs?.watch ?? is_prod_(app_ctx)) {
|
|
56
|
-
await build(esbuild_config)
|
|
57
|
-
} else {
|
|
61
|
+
if (rebuildjs?.watch ?? !is_prod_(app_ctx)) {
|
|
58
62
|
const esbuild_ctx = await context(esbuild_config)
|
|
59
63
|
await esbuild_ctx.watch()
|
|
60
|
-
console.log('
|
|
64
|
+
console.log('browser__build|watch')
|
|
65
|
+
} else {
|
|
66
|
+
await build(esbuild_config)
|
|
61
67
|
}
|
|
68
|
+
await public__cp()
|
|
62
69
|
}
|
|
63
70
|
/**
|
|
64
71
|
* @param {rebuildjs__build_config_T}[config]
|
|
65
|
-
* @returns {Promise<string[]>}
|
|
66
|
-
*/
|
|
67
|
-
export function server__external_(config) {
|
|
68
|
-
return ['bun', 'node_modules/*', ...(config.external || [])]
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* @param {Plugin}config
|
|
72
72
|
* @returns {Promise<void>}
|
|
73
|
-
* @private
|
|
74
73
|
*/
|
|
75
|
-
export async function
|
|
76
|
-
const {
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
export async function server__build(config) {
|
|
75
|
+
const {
|
|
76
|
+
rebuildjs,
|
|
77
|
+
...esbuild__config
|
|
78
|
+
} = config ?? {}
|
|
79
|
+
await rm(server_path_(app_ctx), { recursive: true, force: true })
|
|
79
80
|
const path_a = await new fdir()
|
|
80
|
-
.glob('**/*.
|
|
81
|
+
.glob('**/*.server.{ts,js,tsx,jsx}')
|
|
81
82
|
.withFullPaths()
|
|
82
83
|
.crawl(app_path_(app_ctx))
|
|
83
84
|
.withPromise()
|
|
@@ -87,12 +88,10 @@ export async function browser__build(config) {
|
|
|
87
88
|
entryPoints.push(path)
|
|
88
89
|
}
|
|
89
90
|
const plugins = [rebuildjs__plugin_(), ...(esbuild__config.plugins || [])]
|
|
90
|
-
/** @type {BuildOptions} */
|
|
91
91
|
const esbuild_config = {
|
|
92
92
|
entryNames: '[name]-[hash]',
|
|
93
93
|
assetNames: '[name]-[hash]',
|
|
94
94
|
bundle: true,
|
|
95
|
-
external: [],
|
|
96
95
|
target: 'es2020',
|
|
97
96
|
treeShaking: true,
|
|
98
97
|
minify: is_prod_(app_ctx),
|
|
@@ -100,20 +99,27 @@ export async function browser__build(config) {
|
|
|
100
99
|
...esbuild__config,
|
|
101
100
|
entryPoints,
|
|
102
101
|
format: 'esm',
|
|
103
|
-
platform: '
|
|
102
|
+
platform: 'node',
|
|
104
103
|
absWorkingDir: cwd_(app_ctx),
|
|
105
104
|
metafile: true,
|
|
106
|
-
outdir:
|
|
105
|
+
outdir: server_path_(app_ctx),
|
|
106
|
+
external: server__external_(esbuild__config),
|
|
107
107
|
plugins,
|
|
108
108
|
}
|
|
109
|
-
if (rebuildjs?.watch ?? is_prod_(app_ctx)) {
|
|
110
|
-
await build(esbuild_config)
|
|
111
|
-
} else {
|
|
109
|
+
if (rebuildjs?.watch ?? !is_prod_(app_ctx)) {
|
|
112
110
|
const esbuild_ctx = await context(esbuild_config)
|
|
113
111
|
await esbuild_ctx.watch()
|
|
114
|
-
console.log('
|
|
112
|
+
console.log('server__build|watch')
|
|
113
|
+
} else {
|
|
114
|
+
await build(esbuild_config)
|
|
115
115
|
}
|
|
116
|
-
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* @param {rebuildjs__build_config_T}[config]
|
|
119
|
+
* @returns {Promise<string[]>}
|
|
120
|
+
*/
|
|
121
|
+
export function server__external_(config) {
|
|
122
|
+
return ['bun', 'node_modules/*', ...(config.external || [])]
|
|
117
123
|
}
|
|
118
124
|
/**
|
|
119
125
|
* @returns {Plugin}
|