Aha make sense! thank you!
I'm attempting to use the newly refactored @aws-amplify/ui-react
npm packages, but I'm getting the following compilation warning:
[2020-12-05 22:23:46.005 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/@aws-amplify/ui-components/dist/cjs/index-1f3b9bdc.js", :requires [{:line 1628, :column 73}]}
The referenced code looks like it's doing some weird webpack magic to require files:
return Promise.resolve().then(function () { return _interopNamespace(require(
/* webpackInclude: /\.entry\.js$/ */
/* webpackExclude: /\.system\.entry\.js$/ */
/* webpackMode: "lazy" */
`./${bundleId}.entry.js${ ''}`)); }).then(importedModule => {
{
cmpModules.set(bundleId, importedModule);
}
return importedModule[exportName];
}, consoleError);
I'm not exactly sure what's going on, but it seems like the @aws-amplify/ui-components
package may be requiring webpack to function?
Anyway the end result in the UI is that when I try to use the Amplify UI components I get errors like these in the console:
Module not provided: ./amplify-authenticator.cjs.entry.js
Module not provided: ./amplify-nav_2.cjs.entry.js
These *.entry.js
files exist in the node_modules/@aws-amplify/ui-components/dist/cjs/
directory but it looks like because of the aforementioned error they are not properly getting loaded.
Does anyone know of any workaround to get this working?yeah those references look like it expects webpack
this is not something shadow-cljs understands or can support
Ok thanks @thheller that's kinda what i figured. I'm going to see if I can preprocess the bits that use amplify using webpack and then include into the cljs code..
see https://shadow-cljs.github.io/docs/UsersGuide.html#js-provider :external
. that way you can let webpack process all the npm dependencies together
and let shadow-cljs handle the CLJS parts
this worked great, thanks @thheller!
What version were you having this issue with? We’re using @aws-amplify/ui-react": "0.2.24
with no problem using the defaults for the :browser target. Havent tried the latest version which seems to be https://github.com/aws-amplify/amplify-js/releases/tag/%40aws-amplify%2Fui-react%400.2.31
@rberger I'm using 0.2.31. Good to know that this wasn't an issue for previous versions.
I’ll try the latest version when I get a chance. Seems like such a change shouldn’t happen for any change in minor numbers of the semantic version
I should mention I'm using shadow-cljs 2.11.8 and I'm including the amplify and react dependencies in package.json