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

linaria fails to process imported modules under certain conditions (Node is to blame) #506

Merged
merged 1 commit into from
Feb 9, 2020
Merged

linaria fails to process imported modules under certain conditions (Node is to blame) #506

merged 1 commit into from
Feb 9, 2020

Conversation

dkamyshov
Copy link
Contributor

Hi! Thank you for the great package.

Summary

linaria fails to process imported modules under certain conditions.

The problem is actually with Node, not linaria, see this issue: nodejs/help#2094

Conditions

  1. The module in question must be executed in strict mode.
  2. The module must export a function.
  3. The function must be assigned to an exports variable.

This may seem like a rare scenario, but I guess there are quite a few modules on NPM that use exports this way.

Solution

Wrap the module with an additional function wrapper, like so:

(function (exports) {
  // code
})(exports);

I decided to go just with exports because:

  • it solves the problem
  • changes are minimal
  • other variables (module, etc) are not affected

Test plan

Notes

I would greatly appreciate a new release (like v1.3.2) if this PR gets merged.

@callstack-bot
Copy link

callstack-bot commented Nov 21, 2019

Hey @dkamyshov, thank you for your pull request 🤗.
The coverage report for this branch can be viewed here.

@Anber Anber merged commit 114be0d into callstack:master Feb 9, 2020
@Anber Anber mentioned this pull request Feb 9, 2020
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.

5 participants