Fork me on GitHub
#shadow-cljs
<
2020-12-06
>
wontheone106:12:21

Aha make sense! thank you!

esp106:12:17

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?

esp107:12:09

I should mention I'm using shadow-cljs 2.11.8 and I'm including the amplify and react dependencies in package.json

thheller09:12:10

yeah those references look like it expects webpack

thheller09:12:24

this is not something shadow-cljs understands or can support

esp116:12:39

Ok thanks @U05224H0W 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..

thheller19:12:13

see https://shadow-cljs.github.io/docs/UsersGuide.html#js-provider :external. that way you can let webpack process all the npm dependencies together

thheller19:12:24

and let shadow-cljs handle the CLJS parts

esp121:12:17

this worked great, thanks @U05224H0W!

rberger04:12:28

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

esp120:12:58

@U07GPFFAS I'm using 0.2.31. Good to know that this wasn't an issue for previous versions.

rberger21:12:50

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