@zerotal/core 1.6.0 → 1.6.1
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/CHANGELOG.md +13 -0
- package/package.json +1 -1
- package/src/dev/buildEnv.ts +41 -0
- package/src/dev/index.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,19 @@ follows the Zerotal monorepo's unified versioning.
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [1.6.1] — 2026-08-15
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- **`import.meta.env` is defined for bundled browser builds.** `DEV`, `PROD` and `MODE`,
|
|
16
|
+
set from whether the build is a production one. It is a Vite convention rather than a web
|
|
17
|
+
standard — `import.meta.env` is undefined in a browser module — but enough of the npm
|
|
18
|
+
ecosystem branches on it that a bundler leaving it alone ships code reading a property off
|
|
19
|
+
`undefined`. Bun leaves it alone, so Zerotal defines it.
|
|
20
|
+
|
|
21
|
+
`BASE_URL` and `SSR` are deliberately omitted: Zerotal has its own answers for both, and a
|
|
22
|
+
wrong value is worse than an absent one for a package that feature-detects.
|
|
23
|
+
|
|
11
24
|
## [1.6.0] — 2026-08-15
|
|
12
25
|
|
|
13
26
|
### Added
|
package/package.json
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `import.meta.env` members a bundled browser build is expected to carry.
|
|
3
|
+
*
|
|
4
|
+
* These are a Vite convention, not a web standard — `import.meta.env` is
|
|
5
|
+
* undefined in a browser module — but enough of the npm ecosystem branches on
|
|
6
|
+
* them that a bundler which leaves them alone ships code that reads a property
|
|
7
|
+
* off `undefined`. Bun's bundler leaves them alone, so we define them.
|
|
8
|
+
*
|
|
9
|
+
* The case that found this: the Inertia DevTools browser extension relies on
|
|
10
|
+
* client-side hooks that `createInertiaApp()` enables from its `dev` option,
|
|
11
|
+
* and that option's default is literally `import.meta.env.DEV`. Under Bun that
|
|
12
|
+
* expression survived into the bundle, so the panel reported the app was "not
|
|
13
|
+
* running in dev mode" and told the developer to start a Vite server they do
|
|
14
|
+
* not have — advice that cannot be followed in a Zerotal app.
|
|
15
|
+
*
|
|
16
|
+
* Only the three members whose meaning is unambiguous are defined. `BASE_URL`
|
|
17
|
+
* and `SSR` are deliberately omitted: Zerotal has its own answers for both
|
|
18
|
+
* (`app.assets.prefix`, and SSR being a server concern), and a wrong value is
|
|
19
|
+
* worse than an absent one for a package that feature-detects.
|
|
20
|
+
*
|
|
21
|
+
* @param isProduction Whether this build is for a deployment.
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export function browserEnvDefines(isProduction: boolean): Record<string, string> {
|
|
25
|
+
return {
|
|
26
|
+
// The WHOLE object, not `import.meta.env.DEV` member by member. Adapters write
|
|
27
|
+
// `import.meta.env?.DEV` — optional-chained, which is why an unbundled
|
|
28
|
+
// `import.meta.env` yields `false` instead of throwing — and a define keyed on
|
|
29
|
+
// `import.meta.env.DEV` does not match `import.meta.env?.DEV`, so the member
|
|
30
|
+
// form silently changes nothing. Replacing the object satisfies both spellings.
|
|
31
|
+
//
|
|
32
|
+
// Members this does not name resolve to `undefined` rather than throwing, which
|
|
33
|
+
// is the right answer for a bundler that is not Vite: code that feature-detects
|
|
34
|
+
// `import.meta.env.SSR` or a `VITE_*` variable gets a clean miss.
|
|
35
|
+
"import.meta.env": JSON.stringify({
|
|
36
|
+
DEV: !isProduction,
|
|
37
|
+
PROD: isProduction,
|
|
38
|
+
MODE: isProduction ? "production" : "development",
|
|
39
|
+
}),
|
|
40
|
+
};
|
|
41
|
+
}
|
package/src/dev/index.ts
CHANGED
|
@@ -30,6 +30,7 @@ export type { BuildHookFn, BuildResult } from "./DevBuildHook.ts";
|
|
|
30
30
|
export { DevReloadMiddleware, registerDevHtmlSnippet } from "./DevReloadMiddleware.ts";
|
|
31
31
|
export type { DevHtmlSnippet } from "./DevReloadMiddleware.ts";
|
|
32
32
|
export { DEV_RELOAD_CLIENT } from "./reloadClient.ts";
|
|
33
|
+
export { browserEnvDefines } from "./buildEnv.ts";
|
|
33
34
|
export { detectCssPlugins, buildCssBundle, buildJsBundle } from "./CssPlugins.ts";
|
|
34
35
|
export type { AssetBuildConfig } from "./CssPlugins.ts";
|
|
35
36
|
export { pruneBuildOutput } from "./BuildOutput.ts";
|