-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ContentLayer does not follow the path aliases defined in tsconfig.json #38
Comments
It works perfectly fine in vscode 🤔 here's my tsconfig {
"extends": "@takeda-digital/tsconfig/next.json",
"compilerOptions": {
"baseUrl": "./",
"paths": {
"@/*": ["./*"],
"~/*": ["./.contentlayer/*"]
},
"plugins": [
{
"name": "next"
}
],
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json"
},
"include": [
".",
"types/index.d.ts",
"index.d.ts",
"next-env.d.ts",
"eslint.config.mjs",
"global.d.ts",
"next.config.mjs",
"postcss.config.cjs",
"tailwind.config.ts",
"contentlayer.config.ts",
"**/*.tsx",
".contentlayer/generated",
"**/*.ts",
".next/types/**/*.ts",
"../../reset.d.ts"
],
"exclude": ["node_modules", "public/**/*.js"]
} The {
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./base.json",
"compilerOptions": {
"lib": ["ESNext", "DOM", "DOM.Iterable", "ScriptHost"],
"jsx": "preserve",
"module": "ESNext",
"isolatedModules": true,
"alwaysStrict": true
}
} and the {
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"esModuleInterop": true,
"skipLibCheck": true,
"target": "ES2022",
"lib": ["ES2022", "ScriptHost"],
"allowJs": true,
"declaration": true,
"resolveJsonModule": true,
"moduleDetection": "force",
"isolatedModules": true,
"incremental": true,
"disableSourceOfProjectReferenceRedirect": true,
"strict": true,
"strictNullChecks": true,
"noUncheckedIndexedAccess": true,
"checkJs": true,
"module": "Preserve",
"moduleResolution": "Bundler",
"noEmit": true
},
"exclude": ["node_modules", "build", "dist", ".next/cache"]
} assigning the {
"paths": {
"@/*": ["./*"],
"~/*": ["./.contentlayer/*"]
}
} also ensure that the |
@zhutmost yes, this issues still occurs as indicated by your example. Since contentlayer manages the build step with its own plugin now, it should be a bug that path alias are not treated as external. Instead they should be added to the filter like local files, treated as external and bundled. Let me test if that fixes the issue. |
@zhutmost released as v0.5.1, your example should work now. |
Thanks for the developers' great work.
ContentLayer does NOT follow the path aliases defined in tsconfig.json. So I met such an error:
when I am trying to import some packages in
contentlayer.config.ts
, like this:My path aliases are defined in
tsconfig.json
:Here are some related issues:
paths
are not transformed if not bundling evanw/esbuild#394contentlayer.config.ts
should handle tsconfig paths contentlayerdev/contentlayer#238The text was updated successfully, but these errors were encountered: