Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: enable esModuleInterop #85

Merged
merged 1 commit into from
Sep 20, 2021
Merged

fix: enable esModuleInterop #85

merged 1 commit into from
Sep 20, 2021

Conversation

dpilch
Copy link
Member

@dpilch dpilch commented Sep 16, 2021

Resolves #77

Enable esModuleInterop to fix issue:

TypeError: Cannot read properties of undefined (reading 'createElement')

  11 | const ui_react_1 = require("@aws-amplify/ui-react");
  12 | function Frame1(props) {
  13 |   const {} = props;
> 14 |   return react_1.default.createElement(
  15 |     ui_react_1.View,
  16 |     Object.assign(
  17 |       {

See typescript docs
for details.

The main difference this will add to generated components is the __importDefault shim.

var __importDefault =
  (this && this.__importDefault) ||
  function (mod) {
    return mod && mod.__esModule ? mod : { default: mod };
  };
const react_1 = __importDefault(require("react"));

With this shim react_1.default will not be undefined.

@dpilch dpilch requested a review from johnpc September 16, 2021 21:01
},
}).outputText;

console.log(transpiledCode);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, will fix

@frimfram frimfram self-requested a review September 17, 2021 17:17
Copy link

@johnpc johnpc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its working for my purposes!

@dpilch dpilch merged commit 32eac19 into main Sep 20, 2021
@dpilch dpilch deleted the fix-module-import branch September 20, 2021 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CommonJS generated components are not usable
4 participants