I use next.js. When exporting a type in a file index.ts in a third party package an error occurs.
Module parse failed: Unexpected token (23:7)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> export type { Validate } from './src/nullable'
in package.json, assuming the following dependency is added
"@yourproject/your-project": "file:../your-project",
then in next.config, add transpilePackages: ['@yourproject/your-project'],. This allows the loader to work directly on .ts files.
transpilePackages: ['@yourproject/your-project'],
webpack: (config) => {
config.resolve.extensionAlias = {
".js": [".ts", ".tsx", ".js", ".jsx"],
".mjs": [".mts", ".mjs"],
".cjs": [".cts", ".cjs"],
};
return config;
},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With