Closed Meags27 closed 8 months ago
@Meags27, I'm having trouble reproducing this issue when creating a new Next.JS app on v6. Was this an existing app that you upgraded from v5 and then started experiencing this error with?
@Meags27, I'm having trouble reproducing this issue when creating a new Next.JS app on v6. Was this an existing app that you upgraded from v5 and then started experiencing this error with?
Yes it was an Amplify v5 converted to v6. If I add "type" to the amplify source code, the error goes away but I don't want to have to tweak the library. e.g
Did you still not have the issue with "isolatedModules": true, in tsconfig.json? I have to have it to true to work with Babel/SWC it seems (it auto turns it back on if I try turning it off)
export type {
getHashedPayload,
presignUrl,
PresignUrlOptions,
signRequest,
SignRequestOptions,
} from './middleware/signing/signer/signatureV4';
I am also running into this issue on a Amplify v5 project converted to v6
Really need this to be fixed, as I can't run a production next.js build. It's trying to get me to add the word "type" to tons of amplify files.
e.g node_modules/@aws-amplify/core/src/clients/types/index.ts I went through and added "type" but there's so many other files it wants it.
export {
type Middleware,
type MiddlewareHandler,
type Request,
type Response,
type TransferHandler,
type Endpoint,
} from './core';
export {
type Headers,
type HttpRequest,
type HttpResponse,
type HttpTransferHandler,
type HttpTransferOptions,
type ResponseBodyMixin,
} from './http';
export {
type Credentials,
type EndpointResolverOptions,
type ErrorParser,
type ServiceClientOptions,
} from './aws';
When trying to remove isolatedModules it says
We detected TypeScript in your project and reconfigured your tsconfig.json file for you. Strict-mode is set to false by default.
The following mandatory changes were made to your tsconfig.json:
- isolatedModules was set to true (requirement for SWC / Babel)
I fixed it! @alucio-echen
When I first setup v6 (right when it first came out), some of the imports didn't suggest the right directory properly when I wanted to import methods/types from the aws-amplify library. One of them being the types of the Amplify Config file, being ResourcesConfig and LegacyConfig.
I had them imported as import { LegacyConfig, ResourcesConfig,} from "@aws-amplify/core/src/singleton/types";
But it should be:
import { ResourcesConfig } from "aws-amplify";
import { LegacyConfig } from "aws-amplify/adapter-core";
So I went and changed any imports to the proper ones (the IDE now auto suggests the right one) and now the build works. I hope this helps anyone else who may come across this!
`node_modules/@aws-amplify/auth/src/types/index.ts:49:2 - error TS1205: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.
49 AuthSignInOutput,
node_modules/@aws-amplify/auth/src/types/index.ts:50:2 - error TS1205: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.
50 AuthResetPasswordOutput,
node_modules/@aws-amplify/auth/src/types/index.ts:51:2 - error TS1205: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.
51 AuthUpdateUserAttributeOutput,
node_modules/@aws-amplify/auth/src/types/index.ts:52:2 - error TS1205: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.
52 AuthUpdateUserAttributesOutput,
`
I am facing the similar issue while running tsc command before commiting code.
Could you please help? @Meags27
@gibbsvjy007 and @alucio-echen, can you clarify what version you're currently on of Amplify (e.g. v6.X)? We can reopen this issue or have you create a new one if still blocked.
I'm on 6.0.20 and getting the error.
./node_modules/@aws-amplify/auth/src/providers/cognito/index.ts:31:2
Type error: Re-exporting a type when 'isolatedModules' is enabled requires using 'export type'.
29 | export { autoSignIn } from './apis/autoSignIn';
30 | export {
> 31 | ConfirmResetPasswordInput,
| ^
32 | ConfirmSignInInput,
33 | ConfirmSignUpInput,
34 | ConfirmUserAttributeInput,
Ok in my case my IDE autoimorted the type
import type { ChatCompletionCreateParams } from 'openai/resources/chat/completions';
be careful...
Instead of that it should be
import OpenAI from 'openai';
declare params: OpenAI.ChatCompletionCreateParams;
Before opening, please confirm:
JavaScript Framework
Next.js
Amplify APIs
Not applicable
Amplify Categories
Not applicable
Environment information
Describe the bug
Trying to build a production next.js server with npm run build but have this error from aws-amplify library.
If I try turning isolatedModules to false, it just auto puts it back to true afterwards with this message:
Expected behavior
Compiling a production server without an error
Reproduction steps
npm run build with amplify library and next.js
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
tsconfig.json
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response