amplify (and aws-sdk) has many, many issues with snowpack #718
Replies: 10 comments 16 replies
-
Have you found a solution for this? I'm experiencing the same issues. |
Beta Was this translation helpful? Give feedback.
-
This is evidently caused by the inclusion of spurious shims in the "lib-esm" builds of the var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
import { ConsoleLogger as LoggerClass } from './Logger'; (While they may be necessary for functioning in the target environment, the shims are "spurious" in that they invalidate the files as ES2015 modules.) The error is reported by Rollup for every module in every package. In dev mode, the errors are noisy but appear to be benign. Initial testing indicates that the following workaround (in const fs = require("fs");
// Will be `dev` or `build`. These are the arguments passed to snowpack.
const [, , operation] = process.argv;
module.exports = {
/* ...other config... */
installOptions: {
rollup: {
plugins: [
{
/*
* Work around issue bundling @aws-amplify packages, namely the error:
*
* The 'this' keyword is equivalent to 'undefined' at the top level
* of an ES module, and has been rewritten
*
* These errors arise in the packages' `lib-esm` builds, which are
* mostly ES2015 modules but include shims that trigger Rollup errors.
*
* This workaround redirects requests for the indexes of those
* packages to the single-file dists that Rollup can process.
*
* See https://github.com/pikapkg/snowpack/discussions/718
*/
name: "redirect-aws-amplify",
load(id) {
// This is only needed for (and only works in) production mode,
// though note that in dev mode you still get many warnings.
if (operation === "build") {
const alternate = id.replace(
/@aws-amplify\/(.+?)\/lib-esm\/index\.js$/,
"@aws-amplify/$1/dist/aws-amplify-$1.js"
);
if (alternate !== id) {
return fs.readFileSync(alternate, "utf-8");
}
}
},
},
],
},
},
}; |
Beta Was this translation helpful? Give feedback.
-
@FredKSchott I tried setting
However, the option seems to be interpreted somehow, because if I change
So I'm wondering if when that context value is the same as the warning message, then the warning message is sent anyway... |
Beta Was this translation helpful? Give feedback.
-
Is there any joy with getting AWS Amplify to work with rollup at all? A simple app that breaks: import { AmplifyAuthenticator } from "@aws-amplify/ui-react";
import React from "react";
import ReactDOM from "react-dom";
import "./index.less";
ReactDOM.render(
<div>
<AmplifyAuthenticator />
</div>,
document.getElementById("root")
); With these issues (using
|
Beta Was this translation helpful? Give feedback.
-
Some parts of it are working now with |
Beta Was this translation helpful? Give feedback.
-
I'm getting errors for "url" and "buffer" modules
|
Beta Was this translation helpful? Give feedback.
-
I was adding "@aws-amplify/ui-react" I'm getting with 3.1.0-pre.12:
|
Beta Was this translation helpful? Give feedback.
-
Hi everyone, if you're still having issues with these I'd highly recommend trying the latest rewrite: |
Beta Was this translation helpful? Give feedback.
-
See this comment for a simple workaround.
|
Beta Was this translation helpful? Give feedback.
-
Thanks – that issue was a major annoyance when using aws amplify with snowpack
From: Lukas Jusko ***@***.***>
Sent: Thursday, 25 November 2021 0:45
To: withastro/snowpack ***@***.***>
Cc: akraines ***@***.***>; Mention ***@***.***>
Subject: Re: [withastro/snowpack] amplify (and aws-sdk) has many, many issues with snowpack (Discussion #718)
@akraines <https://github.com/akraines> Can be improved by creating an alias in Snowpack config:
alias: {
'aws-amplify': 'aws-amplify/dist/aws-amplify.min.js'
}
That way you can keep your imports in the code clean:
import Amplify from 'aws-amplify'
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#718 (reply in thread)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/ADT7NB7USGOHMN7QMZWNYRTUNVTFVANCNFSM4PTAJQWA> .
Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub> . <https://github.com/notifications/beacon/ADT7NB2HWWQMAF5UDKWWLSDUNVTFVA5CNFSM4PTAJQWKYY3PNVWWK3TUL52HS4DFWFCGS43DOVZXG2LPNZBW63LNMVXHJKTDN5WW2ZLOORPWSZGOAAM6JJA.gif>
|
Beta Was this translation helpful? Give feedback.
-
Trying to use aws-amplify in a snowpack 2.7.5 site results in many issues including
366 of these:
some node built-in issues (including
url
,buffer
, andevents
):and a wide variety of "could not be resolved", mostly from aws-sdk.
In some cases the file contents of the "es" build seems to be typescript output, including sourcemap comments.
example
Repro and output
Add
aws-amplify
to dependencies in package.json:build output (25k lines)
import something from
aws-amplify
so that snowpack picks it up, like Hub. I did this in App.jsxBeta Was this translation helpful? Give feedback.
All reactions