Javascript 无法解析nextjs中的typescript模块
我有一个带有typescript的小nextjs应用程序,它可以呈现用stenciljs创建的web组件。组件被构建并导出到库Javascript 无法解析nextjs中的typescript模块,javascript,typescript,webpack,next.js,stenciljs,Javascript,Typescript,Webpack,Next.js,Stenciljs,我有一个带有typescript的小nextjs应用程序,它可以呈现用stenciljs创建的web组件。组件被构建并导出到库my components和my components library react(后者是一个封装了组件的库,便于使用react)。我使用tsconfig.json中的path解析模块: { "compilerOptions": { "baseUrl": ".", "paths&qu
my components
和my components library react
(后者是一个封装了组件的库,便于使用react)。我使用tsconfig.json
中的path
解析模块:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"my-components-library-react": ["../my-components-library-react/src/index.ts"]
},
...
}
当我尝试加载模具组件时,接下来会抛出一个错误:
模块分析失败:意外令牌(6:12)
您可能需要适当的加载程序来处理此文件类型,目前没有配置加载程序来处理此文件。看见
从“/react component lib”导入{createReactComponent};
从“我的组件”导入类型{JSX}
编译my components library react
并解析为js文件时,一切正常(“my components library react”:[“./my components library react/dist/index.js”]
)
为什么webpack不能加载外部ts文件以及如何实现这一点?尝试使用编译库。