当尝试从导出Typescript 的私有库导入组件时,我们收到以下错误消息:
Module parse failed: Unexpected token (82: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
|
| // Types
> export type {
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?我尝试在tsconfig文件中显式包含库节点模块:
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
"node_modules/@private-lib/*.*"
],
"exclude": [""]
Run Code Online (Sandbox Code Playgroud)
但不幸的是,没有效果。似乎可以更改next.js的webpack配置,但不幸的是,尝试插入 Typescript 加载器并不起作用:
module.exports = {
webpack: (config, options) => {
config.module.rules.push({
test: /\.(ts|js)x?$/,
use: [
options.defaultLoaders.babel,
{
loader: "ts-loader",
options: {
transpileOnly: true,
experimentalWatchApi: …Run Code Online (Sandbox Code Playgroud)