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] single export TypeError: cannot read properties error #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

debdutdeb
Copy link
Member

@debdutdeb debdutdeb commented Jan 6, 2022

closes #41

@debdutdeb debdutdeb force-pushed the fix/41-single-export branch 3 times, most recently from 3a5b719 to e24c356 Compare January 6, 2022 08:17
Copy link
Member

@d-gubert d-gubert left a comment

Choose a reason for hiding this comment

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

The PR solves that issue, but disregards the comments in the class file:

          * However, we need to handle this case due to backwards compatibility,
          * since the main class file might export a class with an unknown name,
          * which was supported in the early versions of the Apps-Engine.

Which causes apps that don't follow the convention of naming their classes the same as their files to break.

A solution I've found to all these problems is to simply change the if statement in the compiledRequire function as follows:

        if (Object.keys(exports).length === 1 && typeof result === 'function') {
            return result;
        }

This way we are handling the older cases more specifically while fixing the problem.

The other changes are not needed.

@debdutdeb can you apply these changes to the PR? :)

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.

Fix in 0.3.1 causes import bug with module which has only 1 export
2 participants