You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a TS source code where I use fs.readdir to get a list of files I want to dynamically import.
The following code is an example of how do I import the files.
import { readdir } from "fs/promises";
import { resolve } from "path";
async function* getFiles(dir: string): AsyncIterable<string> {
const dirents = await readdir(dir, { withFileTypes: true });
for (const dirent of dirents) {
const res = resolve(dir, dirent.name);
if (dirent.isDirectory()) {
yield* getFiles(res);
} else {
yield res;
}
}
}
const schemaChunks = [];
for await (const f of getFiles(__dirname + "/schemas")) {
const match = f.match(/schemas\/.*Schema.ts/);
if (match)
schemaChunks.push(
await import("./" + match[0]).then(({ typeDefs, resolvers }) => ({
typeDefs,
resolvers,
}))
);
}
Is there any way to force swc to transpile these file, despite the fact swc cannot load get their names, because this information comes at runtime. Can we have a swc config key which can take a glob pattern parameter too force inclusion of some files?
Tanks a lot
The text was updated successfully, but these errors were encountered:
Hi,
I have a TS source code where I use fs.readdir to get a list of files I want to dynamically import.
The following code is an example of how do I import the files.
Is there any way to force swc to transpile these file, despite the fact swc cannot load get their names, because this information comes at runtime. Can we have a swc config key which can take a glob pattern parameter too force inclusion of some files?
Tanks a lot
The text was updated successfully, but these errors were encountered: