fix(app): teach the bundler the repo's .js -> .ts import convention
ci / test-pglite (PGlite, default) (push) Successful in 3m16s
ci / test-postgres (Postgres 16, G-022 RLS) (push) Successful in 1m55s
ci / test-pglite (PGlite, default) (pull_request) Successful in 3m12s
ci / test-postgres (Postgres 16, G-022 RLS) (pull_request) Successful in 1m58s
ci / test-pglite (PGlite, default) (push) Successful in 3m16s
ci / test-postgres (Postgres 16, G-022 RLS) (push) Successful in 1m55s
ci / test-pglite (PGlite, default) (pull_request) Successful in 3m12s
ci / test-postgres (Postgres 16, G-022 RLS) (pull_request) Successful in 1m58s
The control-plane app follows the repo-wide ESM convention - a './x.js' specifier for a './x.ts' source - in all 79 of its relative imports. TypeScript resolves that (moduleResolution: bundler), webpack does not, so the new `next build` gate step failed with "Module not found: Can't resolve '../../../../lib/db.js'" on the first app build this repo ever ran. resolve.extensionAlias maps a '.js' request to the '.ts'/'.tsx' source behind it, so the bundler honours the same convention the type-checker and the packages already do. One resolver-level change, no import churn. Evidence: run 69747, job 72065 - the app-build step fails to compile with 5 module-not-found errors across 4 route files.
This commit is contained in:
@@ -1,5 +1,22 @@
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
transpilePackages: ["@coreci/db", "@coreci/auth", "@coreci/secrets", "@coreci/config", "@coreci/runtime", "@coreci/byom"],
|
||||
// The app follows the repo-wide ESM import convention - a "./x.js" specifier
|
||||
// for a "./x.ts" source - like every package in this repo. TypeScript
|
||||
// resolves that convention (moduleResolution: bundler); the bundler does
|
||||
// not, so `next build` failed with "Module not found: Can't resolve
|
||||
// '../../../../lib/db.js'". resolve.extensionAlias maps a ".js" request to
|
||||
// the ".ts"/".tsx" source behind it, so the bundler honours the same
|
||||
// convention the type-checker and the packages already do - one
|
||||
// resolver-level change, no import churn.
|
||||
webpack: (config) => {
|
||||
config.resolve.extensionAlias = {
|
||||
...config.resolve.extensionAlias,
|
||||
".js": [".ts", ".tsx", ".js"],
|
||||
".mjs": [".mts", ".mjs"],
|
||||
".cjs": [".cts", ".cjs"],
|
||||
};
|
||||
return config;
|
||||
},
|
||||
};
|
||||
export default nextConfig;
|
||||
export default nextConfig;
|
||||
|
||||
Reference in New Issue
Block a user