envapt 7.0.0-next.1 → 7.0.0-next.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # envapt
2
2
 
3
+ ## 7.0.0-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 5384199: The `envapt/browser` and `envapt/workerd` builds are now side-effect-free, so a bundler can drop the parts of envapt a consumer never imports. Importing a single export such as `EnvaptError` or `Converters` from the portable builds now ships about 1.3 kB instead of about 22 kB. The filesystem-only APIs (`envPaths`, `baseDir`, `envFileOptions`, `configureProfiles`, `resetProfiles`) still throw `EnvaptError` on the browser and Workers builds, their stubs moved onto the portable `Envapter` class so they install only when that class is used.
8
+
3
9
  ## 7.0.0-next.1
4
10
 
5
11
  ### Patch Changes
@@ -0,0 +1,2 @@
1
+ import{Envapter as e}from"./Envapter.mjs";import{installFileApiStubs as t}from"./installFileApiStubs.mjs";var n=class n extends e{static{t(n)}};export{n as PortableEnvapter};
2
+ //# sourceMappingURL=PortableEnvapter.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PortableEnvapter.mjs","names":[],"sources":["../../../src/engine/PortableEnvapter.ts"],"sourcesContent":["import { Envapter } from './Envapter';\nimport { installFileApiStubs } from './installFileApiStubs';\n\n/**\n * The browser/Workers facade. {@link Envapter} with the filesystem-only configuration APIs\n * (`envPaths`, `baseDir`, `envFileOptions`, `configureProfiles`, `resetProfiles`) stubbed to throw\n * {@link EnvaptError}. The portable types omit those APIs, so the stubs only guard JS callers that\n * bypass the types.\n * @public\n */\nexport class PortableEnvapter extends Envapter {\n // A static block (not a top-level statement in a separate entry) keeps the stub install intrinsic to\n // this class, so it tree-shakes out of a leaf import and needs no sideEffects entry. Depends on the\n // es2022 native static-block emit, lowering the target defeats it.\n static {\n installFileApiStubs(PortableEnvapter);\n }\n}\n"],"mappings":"0GAUA,IAAa,EAAb,MAAa,UAAyB,CAAS,CAI3C,OACI,EAAoB,CAAgB,CACxC,CACJ"}
@@ -1,2 +1,2 @@
1
- import{EnvaptError as e}from"../infra/Error.mjs";import{Envapter as t}from"./Envapter.mjs";const n=[`envPaths`,`baseDir`,`envFileOptions`,`configureProfiles`,`resetProfiles`];function r(t){throw new e(306,`Envapter.${t} requires a filesystem-backed source and is not available in this build.`)}function i(){for(let e of n)Object.defineProperty(t,e,{configurable:!0,get:()=>r(e),set:()=>r(e)})}export{i as installFileApiStubs};
1
+ import{EnvaptError as e}from"../infra/Error.mjs";const t=[`envPaths`,`baseDir`,`envFileOptions`,`configureProfiles`,`resetProfiles`];function n(t){throw new e(306,`Envapter.${t} requires a filesystem-backed source and is not available in this build.`)}function r(e){for(let r of t)Object.defineProperty(e,r,{configurable:!0,get:()=>n(r),set:()=>n(r)})}export{r as installFileApiStubs};
2
2
  //# sourceMappingURL=installFileApiStubs.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"installFileApiStubs.mjs","names":[],"sources":["../../../src/engine/installFileApiStubs.ts"],"sourcesContent":["import { Envapter } from './Envapter';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nconst FILE_ONLY_APIS = ['envPaths', 'baseDir', 'envFileOptions', 'configureProfiles', 'resetProfiles'] as const;\n\nfunction fileApiUnsupported(api: string): never {\n throw new EnvaptError(\n EnvaptErrorCodes.FileApiUnsupported,\n `Envapter.${api} requires a filesystem-backed source and is not available in this build.`\n );\n}\n\n// Call from each entry's own top level, not via `export * from` another entry: the build tree-shakes a\n// re-exported entry's side effect away, which would silently drop these stubs from that entry's output.\nexport function installFileApiStubs(): void {\n for (const api of FILE_ONLY_APIS) {\n Object.defineProperty(Envapter, api, {\n configurable: true,\n get: () => fileApiUnsupported(api),\n set: () => fileApiUnsupported(api)\n });\n }\n}\n"],"mappings":"2FAGA,MAAM,EAAiB,CAAC,WAAY,UAAW,iBAAkB,oBAAqB,eAAe,EAErG,SAAS,EAAmB,EAAoB,CAC5C,MAAM,IAAI,EAAA,IAEN,YAAY,EAAI,yEACpB,CACJ,CAIA,SAAgB,GAA4B,CACxC,IAAK,IAAM,KAAO,EACd,OAAO,eAAe,EAAU,EAAK,CACjC,aAAc,GACd,QAAW,EAAmB,CAAG,EACjC,QAAW,EAAmB,CAAG,CACrC,CAAC,CAET"}
1
+ {"version":3,"file":"installFileApiStubs.mjs","names":[],"sources":["../../../src/engine/installFileApiStubs.ts"],"sourcesContent":["import { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nconst FILE_ONLY_APIS = ['envPaths', 'baseDir', 'envFileOptions', 'configureProfiles', 'resetProfiles'] as const;\n\nfunction fileApiUnsupported(api: string): never {\n throw new EnvaptError(\n EnvaptErrorCodes.FileApiUnsupported,\n `Envapter.${api} requires a filesystem-backed source and is not available in this build.`\n );\n}\n\n// Call from a class static block, not an entry top level, or the build drops the stubs from a\n// re-exported entry as a tree-shaken side effect.\nexport function installFileApiStubs(target: object): void {\n for (const api of FILE_ONLY_APIS) {\n Object.defineProperty(target, api, {\n configurable: true,\n get: () => fileApiUnsupported(api),\n set: () => fileApiUnsupported(api)\n });\n }\n}\n"],"mappings":"iDAEA,MAAM,EAAiB,CAAC,WAAY,UAAW,iBAAkB,oBAAqB,eAAe,EAErG,SAAS,EAAmB,EAAoB,CAC5C,MAAM,IAAI,EAAA,IAEN,YAAY,EAAI,yEACpB,CACJ,CAIA,SAAgB,EAAoB,EAAsB,CACtD,IAAK,IAAM,KAAO,EACd,OAAO,eAAe,EAAQ,EAAK,CAC/B,aAAc,GACd,QAAW,EAAmB,CAAG,EACjC,QAAW,EAAmB,CAAG,CACrC,CAAC,CAET"}
@@ -1,2 +1 @@
1
- import{Converters as e,isArrayOf as t}from"./converters/Converters.mjs";import{EnvaptError as n,EnvaptErrorCodes as r}from"./infra/Error.mjs";import{Environment as i}from"./core/EnvironmentMethods.mjs";import{Envapter as a}from"./engine/Envapter.mjs";import{installFileApiStubs as o}from"./engine/installFileApiStubs.mjs";import{ManualEnvSource as s}from"./sources/ManualEnvSource.mjs";import{WorkerEnvSource as c}from"./sources/WorkerEnvSource.mjs";import{Envapt as l}from"./decorators/modern/Envapt.mjs";import{EnvBool as u,EnvNum as d,EnvStr as f,EnvTime as p,EnvUrl as m}from"./decorators/modern/SugarDecorators.mjs";o();export{e as Converters,u as EnvBool,d as EnvNum,f as EnvStr,p as EnvTime,m as EnvUrl,l as Envapt,n as EnvaptError,r as EnvaptErrorCodes,a as Envapter,i as Environment,s as ManualEnvSource,c as WorkerEnvSource,t as isArrayOf};
2
- //# sourceMappingURL=index.mjs.map
1
+ import{Converters as e,isArrayOf as t}from"./converters/Converters.mjs";import{EnvaptError as n,EnvaptErrorCodes as r}from"./infra/Error.mjs";import{Environment as i}from"./core/EnvironmentMethods.mjs";import{ManualEnvSource as a}from"./sources/ManualEnvSource.mjs";import{WorkerEnvSource as o}from"./sources/WorkerEnvSource.mjs";import{Envapt as s}from"./decorators/modern/Envapt.mjs";import{EnvBool as c,EnvNum as l,EnvStr as u,EnvTime as d,EnvUrl as f}from"./decorators/modern/SugarDecorators.mjs";import{PortableEnvapter as p}from"./engine/PortableEnvapter.mjs";export{e as Converters,c as EnvBool,l as EnvNum,u as EnvStr,d as EnvTime,f as EnvUrl,s as Envapt,n as EnvaptError,r as EnvaptErrorCodes,p as Envapter,i as Environment,a as ManualEnvSource,o as WorkerEnvSource,t as isArrayOf};
@@ -0,0 +1,14 @@
1
+ import { Envapter } from "./Envapter.mjs";
2
+
3
+ //#region src/engine/PortableEnvapter.d.ts
4
+ /**
5
+ * The browser/Workers facade. {@link Envapter} with the filesystem-only configuration APIs
6
+ * (`envPaths`, `baseDir`, `envFileOptions`, `configureProfiles`, `resetProfiles`) stubbed to throw
7
+ * {@link EnvaptError}. The portable types omit those APIs, so the stubs only guard JS callers that
8
+ * bypass the types.
9
+ * @public
10
+ */
11
+ declare class PortableEnvapter extends Envapter {}
12
+ //#endregion
13
+ export { PortableEnvapter };
14
+ //# sourceMappingURL=PortableEnvapter.d.mts.map
@@ -9,10 +9,10 @@ import { EnvProfile, EnvaptOptions, ProfilesConfig } from "./types/Options.mjs";
9
9
  import { EnvKeyInput } from "./types/Env.mjs";
10
10
  import { BareEnvSource, EnvSource, FileEnvSource } from "./types/Source.mjs";
11
11
  import { EnvaptAccessorDecorator, EnvaptFieldDecorator } from "./types/Decorator.mjs";
12
- import { Envapter } from "./engine/Envapter.mjs";
13
12
  import { ManualEnvSource } from "./sources/ManualEnvSource.mjs";
14
13
  import { WorkerEnvSource } from "./sources/WorkerEnvSource.mjs";
15
14
  import { EnvaptError, EnvaptErrorCodes } from "./infra/Error.mjs";
16
15
  import { Envapt } from "./decorators/modern/Envapt.mjs";
17
16
  import { EnvBool, EnvNum, EnvStr, EnvTime, EnvUrl } from "./decorators/modern/SugarDecorators.mjs";
18
- export { type AdvancedConverterReturn, type ArrayElement, type ArrayOf, type BareEnvSource, type BuiltInConverter, type BuiltInConverterFunction, type ConditionalReturn, type ConverterFunction, type ConverterToken, Converters, type CustomElementConverter, type DebugLevel, EnvBool, type EnvFileOptions, type EnvKeyInput, EnvNum, type EnvProfile, type EnvSource, EnvStr, EnvTime, EnvUrl, Envapt, type EnvaptAccessorDecorator, type EnvaptConverter, EnvaptError, EnvaptErrorCodes, type EnvaptFieldDecorator, type EnvaptOptions, Envapter, Environment, type Err, type FileEnvSource, type InferConverterFallbackType, type InferConverterReturnType, type InferPrimitiveReturnType, type InferSchemaInput, type InferSchemaOutput, type JsonValue, ManualEnvSource, type MapOfConverterFunctions, type PrimitiveConstructor, type ProfilesConfig, type SchemaConstraint, type SchemaMustBeSync, type StandardSchemaV1, type TimeFallback, type TimeUnit, WorkerEnvSource, isArrayOf };
17
+ import { PortableEnvapter } from "./engine/PortableEnvapter.mjs";
18
+ export { type AdvancedConverterReturn, type ArrayElement, type ArrayOf, type BareEnvSource, type BuiltInConverter, type BuiltInConverterFunction, type ConditionalReturn, type ConverterFunction, type ConverterToken, Converters, type CustomElementConverter, type DebugLevel, EnvBool, type EnvFileOptions, type EnvKeyInput, EnvNum, type EnvProfile, type EnvSource, EnvStr, EnvTime, EnvUrl, Envapt, type EnvaptAccessorDecorator, type EnvaptConverter, EnvaptError, EnvaptErrorCodes, type EnvaptFieldDecorator, type EnvaptOptions, PortableEnvapter as Envapter, Environment, type Err, type FileEnvSource, type InferConverterFallbackType, type InferConverterReturnType, type InferPrimitiveReturnType, type InferSchemaInput, type InferSchemaOutput, type JsonValue, ManualEnvSource, type MapOfConverterFunctions, type PrimitiveConstructor, type ProfilesConfig, type SchemaConstraint, type SchemaMustBeSync, type StandardSchemaV1, type TimeFallback, type TimeUnit, WorkerEnvSource, isArrayOf };
@@ -0,0 +1,2 @@
1
+ import{Envapter as e}from"./Envapter.mjs";import{installFileApiStubs as t}from"./installFileApiStubs.mjs";var n=class n extends e{static{t(n)}};export{n as PortableEnvapter};
2
+ //# sourceMappingURL=PortableEnvapter.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PortableEnvapter.mjs","names":[],"sources":["../../../src/engine/PortableEnvapter.ts"],"sourcesContent":["import { Envapter } from './Envapter';\nimport { installFileApiStubs } from './installFileApiStubs';\n\n/**\n * The browser/Workers facade. {@link Envapter} with the filesystem-only configuration APIs\n * (`envPaths`, `baseDir`, `envFileOptions`, `configureProfiles`, `resetProfiles`) stubbed to throw\n * {@link EnvaptError}. The portable types omit those APIs, so the stubs only guard JS callers that\n * bypass the types.\n * @public\n */\nexport class PortableEnvapter extends Envapter {\n // A static block (not a top-level statement in a separate entry) keeps the stub install intrinsic to\n // this class, so it tree-shakes out of a leaf import and needs no sideEffects entry. Depends on the\n // es2022 native static-block emit, lowering the target defeats it.\n static {\n installFileApiStubs(PortableEnvapter);\n }\n}\n"],"mappings":"0GAUA,IAAa,EAAb,MAAa,UAAyB,CAAS,CAI3C,OACI,EAAoB,CAAgB,CACxC,CACJ"}
@@ -1,2 +1,2 @@
1
- import{EnvaptError as e}from"../infra/Error.mjs";import{Envapter as t}from"./Envapter.mjs";const n=[`envPaths`,`baseDir`,`envFileOptions`,`configureProfiles`,`resetProfiles`];function r(t){throw new e(306,`Envapter.${t} requires a filesystem-backed source and is not available in this build.`)}function i(){for(let e of n)Object.defineProperty(t,e,{configurable:!0,get:()=>r(e),set:()=>r(e)})}export{i as installFileApiStubs};
1
+ import{EnvaptError as e}from"../infra/Error.mjs";const t=[`envPaths`,`baseDir`,`envFileOptions`,`configureProfiles`,`resetProfiles`];function n(t){throw new e(306,`Envapter.${t} requires a filesystem-backed source and is not available in this build.`)}function r(e){for(let r of t)Object.defineProperty(e,r,{configurable:!0,get:()=>n(r),set:()=>n(r)})}export{r as installFileApiStubs};
2
2
  //# sourceMappingURL=installFileApiStubs.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"installFileApiStubs.mjs","names":[],"sources":["../../../src/engine/installFileApiStubs.ts"],"sourcesContent":["import { Envapter } from './Envapter';\nimport { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nconst FILE_ONLY_APIS = ['envPaths', 'baseDir', 'envFileOptions', 'configureProfiles', 'resetProfiles'] as const;\n\nfunction fileApiUnsupported(api: string): never {\n throw new EnvaptError(\n EnvaptErrorCodes.FileApiUnsupported,\n `Envapter.${api} requires a filesystem-backed source and is not available in this build.`\n );\n}\n\n// Call from each entry's own top level, not via `export * from` another entry: the build tree-shakes a\n// re-exported entry's side effect away, which would silently drop these stubs from that entry's output.\nexport function installFileApiStubs(): void {\n for (const api of FILE_ONLY_APIS) {\n Object.defineProperty(Envapter, api, {\n configurable: true,\n get: () => fileApiUnsupported(api),\n set: () => fileApiUnsupported(api)\n });\n }\n}\n"],"mappings":"2FAGA,MAAM,EAAiB,CAAC,WAAY,UAAW,iBAAkB,oBAAqB,eAAe,EAErG,SAAS,EAAmB,EAAoB,CAC5C,MAAM,IAAI,EAAA,IAEN,YAAY,EAAI,yEACpB,CACJ,CAIA,SAAgB,GAA4B,CACxC,IAAK,IAAM,KAAO,EACd,OAAO,eAAe,EAAU,EAAK,CACjC,aAAc,GACd,QAAW,EAAmB,CAAG,EACjC,QAAW,EAAmB,CAAG,CACrC,CAAC,CAET"}
1
+ {"version":3,"file":"installFileApiStubs.mjs","names":[],"sources":["../../../src/engine/installFileApiStubs.ts"],"sourcesContent":["import { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nconst FILE_ONLY_APIS = ['envPaths', 'baseDir', 'envFileOptions', 'configureProfiles', 'resetProfiles'] as const;\n\nfunction fileApiUnsupported(api: string): never {\n throw new EnvaptError(\n EnvaptErrorCodes.FileApiUnsupported,\n `Envapter.${api} requires a filesystem-backed source and is not available in this build.`\n );\n}\n\n// Call from a class static block, not an entry top level, or the build drops the stubs from a\n// re-exported entry as a tree-shaken side effect.\nexport function installFileApiStubs(target: object): void {\n for (const api of FILE_ONLY_APIS) {\n Object.defineProperty(target, api, {\n configurable: true,\n get: () => fileApiUnsupported(api),\n set: () => fileApiUnsupported(api)\n });\n }\n}\n"],"mappings":"iDAEA,MAAM,EAAiB,CAAC,WAAY,UAAW,iBAAkB,oBAAqB,eAAe,EAErG,SAAS,EAAmB,EAAoB,CAC5C,MAAM,IAAI,EAAA,IAEN,YAAY,EAAI,yEACpB,CACJ,CAIA,SAAgB,EAAoB,EAAsB,CACtD,IAAK,IAAM,KAAO,EACd,OAAO,eAAe,EAAQ,EAAK,CAC/B,aAAc,GACd,QAAW,EAAmB,CAAG,EACjC,QAAW,EAAmB,CAAG,CACrC,CAAC,CAET"}
@@ -1,2 +1 @@
1
- import{Converters as e,isArrayOf as t}from"./converters/Converters.mjs";import{EnvaptError as n,EnvaptErrorCodes as r}from"./infra/Error.mjs";import{Environment as i}from"./core/EnvironmentMethods.mjs";import{Envapter as a}from"./engine/Envapter.mjs";import{installFileApiStubs as o}from"./engine/installFileApiStubs.mjs";import{ManualEnvSource as s}from"./sources/ManualEnvSource.mjs";import{WorkerEnvSource as c}from"./sources/WorkerEnvSource.mjs";import{Envapt as l}from"./decorators/modern/Envapt.mjs";import{EnvBool as u,EnvNum as d,EnvStr as f,EnvTime as p,EnvUrl as m}from"./decorators/modern/SugarDecorators.mjs";o();export{e as Converters,u as EnvBool,d as EnvNum,f as EnvStr,p as EnvTime,m as EnvUrl,l as Envapt,n as EnvaptError,r as EnvaptErrorCodes,a as Envapter,i as Environment,s as ManualEnvSource,c as WorkerEnvSource,t as isArrayOf};
2
- //# sourceMappingURL=index.mjs.map
1
+ import{Converters as e,isArrayOf as t}from"./converters/Converters.mjs";import{EnvaptError as n,EnvaptErrorCodes as r}from"./infra/Error.mjs";import{Environment as i}from"./core/EnvironmentMethods.mjs";import{ManualEnvSource as a}from"./sources/ManualEnvSource.mjs";import{WorkerEnvSource as o}from"./sources/WorkerEnvSource.mjs";import{Envapt as s}from"./decorators/modern/Envapt.mjs";import{EnvBool as c,EnvNum as l,EnvStr as u,EnvTime as d,EnvUrl as f}from"./decorators/modern/SugarDecorators.mjs";import{PortableEnvapter as p}from"./engine/PortableEnvapter.mjs";export{e as Converters,c as EnvBool,l as EnvNum,u as EnvStr,d as EnvTime,f as EnvUrl,s as Envapt,n as EnvaptError,r as EnvaptErrorCodes,p as Envapter,i as Environment,a as ManualEnvSource,o as WorkerEnvSource,t as isArrayOf};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "envapt",
3
3
  "type": "module",
4
- "version": "7.0.0-next.1",
4
+ "version": "7.0.0-next.2",
5
5
  "description": "Type-safe config for TypeScript. Read typed values from any source, process.env, .env files, Cloudflare Workers bindings, browser bundles, or any object you supply. Zero runtime dependencies, one API across Node, Bun, Deno, Workers, and the browser. TC39 accessor decorators (legacy decorators at envapt/legacy), converters, and Standard Schema (zod/valibot/arktype) validation.",
6
6
  "types": "./dist/types/index.d.mts",
7
7
  "exports": {
@@ -86,9 +86,7 @@
86
86
  },
87
87
  "sideEffects": [
88
88
  "./dist/node/config.cjs",
89
- "./dist/node/config.mjs",
90
- "./dist/browser/index.mjs",
91
- "./dist/workerd/index.mjs"
89
+ "./dist/node/config.mjs"
92
90
  ],
93
91
  "files": [
94
92
  "dist/**/*.mjs",
@@ -171,6 +169,7 @@
171
169
  "test:workers": "tsc --noEmit -p tests/workers/tsconfig.json && vitest run --config vitest.workers.config.ts",
172
170
  "test:browser": "tsc --noEmit -p tests/browser/tsconfig.json && vitest run --config vitest.browser.config.ts",
173
171
  "test:consumer-build": "node tests/consumer-build/run.mjs",
172
+ "test:tree-shaking": "node tests/tree-shaking/run.mjs",
174
173
  "test:exports-dedup": "node tests/exports-dedup/run.mjs",
175
174
  "test:tsc-emit": "node tests/tsc-emit/run.mjs",
176
175
  "test:stage3-emit": "node tests/stage3-emit/run.mjs",
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/browser.ts"],"sourcesContent":["import { installFileApiStubs } from './engine/installFileApiStubs';\n\nexport * from './index.portable';\n\ninstallFileApiStubs();\n"],"mappings":"6mBAIA,EAAoB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/workerd.ts"],"sourcesContent":["import { installFileApiStubs } from './engine/installFileApiStubs';\n\nexport * from './browser';\n\ninstallFileApiStubs();\n"],"mappings":"6mBAIA,EAAoB"}