shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
wontheone1 2020-12-06T06:30:21.371Z

Aha make sense! thank you!

esp1 2020-12-06T06:51:17.377200Z

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?

thheller 2020-12-06T09:58:10.377500Z

yeah those references look like it expects webpack

thheller 2020-12-06T09:58:24.377700Z

this is not something shadow-cljs understands or can support

esp1 2020-12-06T16:22:39.377900Z

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..

thheller 2020-12-06T19:45:13.378100Z

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

thheller 2020-12-06T19:45:24.378300Z

and let shadow-cljs handle the CLJS parts

esp1 2020-12-07T21:59:17.397800Z

this worked great, thanks @thheller!

rberger 2020-12-08T04:58:28.398Z

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

esp1 2020-12-08T20:29:58.398200Z

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

rberger 2020-12-08T21:48:50.398400Z

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

esp1 2020-12-06T07:14:09.377300Z

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