Я преобразовал свой запрос GraphQL и компонент HOC в машинописный текст, и теперь получаю следующую ошибку:
ERROR in ./client/components/Protected.Route.tsx
Module build failed: Error: Final loader (./node_modules/awesome-typescript-loader/dist/entry.js) didn't return a Buffer or String
at runLoaders (/Users/rsokz/Documents/Projects/ReactWorkspace/mydash/auth-graphql-starter/node_modules/webpack/lib/NormalModule.js:318:18)
at /Users/rsokz/Documents/Projects/ReactWorkspace/mydash/auth-graphql-starter/node_modules/loader-runner/lib/LoaderRunner.js:373:3
at iterateNormalLoaders (/Users/rsokz/Documents/Projects/ReactWorkspace/mydash/auth-graphql-starter/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
at iterateNormalLoaders (/Users/rsokz/Documents/Projects/ReactWorkspace/mydash/auth-graphql-starter/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
at /Users/rsokz/Documents/Projects/ReactWorkspace/mydash/auth-graphql-starter/node_modules/loader-runner/lib/LoaderRunner.js:236:3
at context.callback (/Users/rsokz/Documents/Projects/ReactWorkspace/mydash/auth-graphql-starter/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
at process._tickCallback (internal/process/next_tick.js:68:7)
@ ./client/components/App.js 5:0-47 12:59-73
@ ./client/index.js
ERROR in ./client/graphql/queries/currentUser.ts
Module build failed: Error: Final loader (./node_modules/awesome-typescript-loader/dist/entry.js) didn't return a Buffer or String
at runLoaders (/Users/rsokz/Documents/Projects/ReactWorkspace/mydash/auth-graphql-starter/node_modules/webpack/lib/NormalModule.js:318:18)
at /Users/rsokz/Documents/Projects/ReactWorkspace/mydash/auth-graphql-starter/node_modules/loader-runner/lib/LoaderRunner.js:373:3
at iterateNormalLoaders (/Users/rsokz/Documents/Projects/ReactWorkspace/mydash/auth-graphql-starter/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
at iterateNormalLoaders (/Users/rsokz/Documents/Projects/ReactWorkspace/mydash/auth-graphql-starter/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
at /Users/rsokz/Documents/Projects/ReactWorkspace/mydash/auth-graphql-starter/node_modules/loader-runner/lib/LoaderRunner.js:236:3
at context.callback (/Users/rsokz/Documents/Projects/ReactWorkspace/mydash/auth-graphql-starter/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
at process._tickCallback (internal/process/next_tick.js:68:7)
@ ./client/components/Auth/AuthForm.jsx 50:0-65 104:17-33 136:17-33 216:12-28
@ ./client/components/App.js
@ ./client/index.js
Я перепробовал почти все, что нашел в Интернете.allowJs
установлен в true
в tsconfig.Мы будем благодарны за любую помощь.
Версии:
Машинопись: 3.1.6
Веб-пакет: 4.29.3
загрузчик: 5.2.1
Это код для Protected.Route.tsx
:
import * as React from 'react';
import { Route, Redirect, RouteProps } from 'react-router-dom';
import { Query } from 'react-apollo';
import currentUserQuery from '../graphql/queries/currentUser';
interface ProtectedRouteProps extends RouteProps {
component: React.ComponentType<RouteProps>;
}
const ProtectedRoute = ({ component: Component, ...rest }: ProtectedRouteProps) => (
<Route
{...rest}
render={props => {
<Query query={currentUserQuery}>
{({ loading, data: { currentUser } }) => {
if (loading) return null;
if (currentUser) {
return <Component {...props} />;
}
}}
</Query>;
return (
<Redirect
to={{
pathname: '/login',
state: {
from: props.location
}
}}
/>
);
}}
/>
);
export default ProtectedRoute;
И код для currentUser.ts
:
import { gql } from 'apollo-boost';
export default gql`
{
currentUser {
id
email
name
}
}
`;
webpack.config.js
module.exports = {
entry: './client/index.js',
output: {
path: '/',
filename: 'bundle.js'
},
module: {
rules: [
{
use: 'babel-loader',
test: /\.jsx?$/,
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json']
},
exclude: /node_modules/
},
{
test: /\.tsx?$/,
loader: 'awesome-typescript-loader',
options: {
getCustomTransformers: () => ({ before: [styledComponentsTransformer] })
}
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: 'client/index.html'
})
]
};