analytics icon indicating copy to clipboard operation
analytics copied to clipboard

Unable to load @analytics/aws-pinpoint via (Dojo) AMD loader

Open tomwayson opened this issue 3 years ago • 0 comments

I have a library that imports from analytics and @analytics/aws-pinpoint.

We distribute a UMD bundle that we build with rollup. Because of an underlying issue w/ @aws-sdk/client-pinpoint causing the bundle to require several node built-ins (crypto, fs, etc) we end up having to exclude @analytics/aws-pinpoint from our bundle. We are able to then successfully use our UMD bundle by using <script> tags that use the globals. For example, you would add the following to your HTML:

<script src="https://unpkg.com/@analytics/[email protected]/dist/@analytics/aws-pinpoint.js"></script>
<script src="./path/to/our/library.js"></script>

And then our library is able to use the analyticsAWSPinpoint global and everything works fine.

However, we have a client that uses Dojo to build their application, and when we they configure the Dojo AMD loader to load @analytics/aws-pinpoint (i.e. like: dojoConfig.paths['@analytics/aws-pinpoint'] = 'https://unpkg.com/@analytics/[email protected]/dist/@analytics/aws-pinpoint' our library fails when trying to read the value exported by that package. It's as if nothing is exported.

Maybe this is a known issue b/c I see that most of the other @analytics packages distribute a umd build, so maybe you ran into the same issues that I did when trying to bundle the underlying @aws-sdk/client-pinpoint and therefore we should not expect @analytics/aws-pinpoint to work in AMD loaders?

tomwayson avatar Sep 02 '22 19:09 tomwayson