Node: JSON configs are read as data, not imported (store-only apps failed under npx: needs an import attribute); test, pitfall 105
This commit is contained in:
parent
bd316723f5
commit
d3d31d6c12
4 changed files with 24 additions and 0 deletions
|
|
@ -82,6 +82,9 @@ export const importPath = (path: string): Promise<any> => import(pathToFileURL(p
|
|||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export async function importConfigModule(path: string): Promise<any> {
|
||||
// a JSON config is read, not imported: Node refuses a JSON import without `with { type: 'json' }` (every store-only
|
||||
// app of `storebound watch` on a server failed; pitfall 105)
|
||||
if (/\.json$/i.test(path)) return { default: JSON.parse(readFileSync(path, 'utf8')) };
|
||||
if (isBun || !/\.[cm]?ts$/.test(path)) return importPath(path);
|
||||
try {
|
||||
return await withoutTypeStripWarning(() => importPath(path));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue