You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I import utils with an alias, the editor throws 3 errors:
Expected 'from' and instead saw '}'.
Expected '(string)' and instead saw 'from'.
Missing ";" before statement
This may seem like a bit of a useless thing to fix, because why would you use anything other than import {util} from "@aws-appsync/utils" to import utils?
Well, I'm following these directions to compile my resolvers with esbuild. When my main resolver file imports utils and imports another custom module that also imports utils, esbuild will insert duplicate import statements, one for each file that imports it:
import { util as util3 } from "@aws-appsync/utils";
import { util } from "@aws-appsync/utils";
import { util as util2 } from "@aws-appsync/utils";
It appears that this has been a known issue in esbuild for years and has not yet been fixed, and it doesn't seem like there's a way around it, so it would be great if AppSync could handle it appropriately.
edit: this also might be breaking source maps. I modified my build process to keep the first util import and remove the rest, but received an error (with no other details) when saving the code. Removing the source map fixed that. I can't tell if this is due to issues parsing the source map because the sources it's referring to are gone or simply because the source map was too long.
The text was updated successfully, but these errors were encountered:
jbschooley
changed the title
Appsync JS doesn't recognize import aliases
Appsync JS doesn't recognize import aliases, breaking resolvers built with esbuild
Apr 13, 2023
Hey, this is an issue that occurs in the AWS console editor. It shows warnings but you can still save your code. Saving your codes with these imports will work. Can you confirm that is the case?
(we are currently looking at fixing this in the console)
It does look like saving code still works, even with the errors. I just tried pushing my stack with the duplicate imports and it worked, I'm not sure why it wasn't going through a few days ago.
The source map issue is still there, and I wonder if it's related to this. When I try to push code with the source map it saves if there's only one util import, but if there's duplicate util imports it throws that vague error.
If I import
utils
with an alias, the editor throws 3 errors:This may seem like a bit of a useless thing to fix, because why would you use anything other than
import {util} from "@aws-appsync/utils"
to import utils?Well, I'm following these directions to compile my resolvers with esbuild. When my main resolver file imports utils and imports another custom module that also imports utils, esbuild will insert duplicate import statements, one for each file that imports it:
It appears that this has been a known issue in esbuild for years and has not yet been fixed, and it doesn't seem like there's a way around it, so it would be great if AppSync could handle it appropriately.
edit: this also might be breaking source maps. I modified my build process to keep the first util import and remove the rest, but received an error (with no other details) when saving the code. Removing the source map fixed that. I can't tell if this is due to issues parsing the source map because the sources it's referring to are gone or simply because the source map was too long.
The text was updated successfully, but these errors were encountered: