Skip to content

Commit d064dbd

Browse files
committed
fix: adds a resolveDir and watchFiles for robustness
1 parent 7f10d04 commit d064dbd

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

app-config-esbuild/src/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Plugin } from 'esbuild';
2+
import path from 'path';
23
import { ConfigLoadingOptions, loadValidatedConfig } from '@app-config/config';
34
import { generateModuleText, packageNameRegex } from '@app-config/utils';
45
import type { SchemaLoadingOptions } from '@app-config/schema';
@@ -24,10 +25,8 @@ export const createPlugin = ({
2425
}));
2526

2627
build.onLoad({ filter: /.*/, namespace: '@app-config/esbuild' }, async () => {
27-
const { fullConfig, environment, validationFunctionCode } = await loadValidatedConfig(
28-
loadingOptions,
29-
schemaLoadingOptions,
30-
);
28+
const { fullConfig, environment, validationFunctionCode, filePaths } =
29+
await loadValidatedConfig(loadingOptions, schemaLoadingOptions);
3130

3231
const code = generateModuleText(fullConfig, {
3332
environment,
@@ -39,6 +38,8 @@ export const createPlugin = ({
3938
return {
4039
loader: 'js',
4140
contents: code,
41+
resolveDir: path.parse(process.cwd()).root,
42+
watchFiles: filePaths,
4243
};
4344
});
4445
},

examples/esbuild-project/.app-config.schema.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ additionalProperties: false
33

44
properties:
55
foo:
6-
type: string
6+
type: string
7+
format: uri
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
foo: bar
1+
foo: http://google.ca

0 commit comments

Comments
 (0)