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 shaker shaking exported value with exports #804

Closed
Tracked by #18936
ling1726 opened this issue Jul 21, 2021 · 0 comments
Closed
Tracked by #18936

Linaria shaker shaking exported value with exports #804

ling1726 opened this issue Jul 21, 2021 · 0 comments
Assignees
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided needs: triage 🏷 Issue needs to be checked and prioritized

Comments

@ling1726
Copy link

ling1726 commented Jul 21, 2021

Environment

  • Linaria version: @linaria/babel-preset@3.0.0-beta.7, @linaria/shaker@3.0.0-beta.8
  • Bundler (+ version): N/A
  • Node.js version: 12.18.4 (Ubuntu)
  • OS: Windows 10, Ubuntu 20.04 LTS on WSL

Description

We use @linaria/babel-preset & @linaria/shaker for our CSS-in-JS in Fluent UI. Please check out the reproducible demo on stackblitz. for code examples.

One of the Typescript targets we build is common-js. It seems that Linaria cannot handle reuse of exported functions with exports because they are getting shaken by the shaker

// 👇👇👇 This is getting shaken by the shaker
var bar = function () { return 'hello world'; }
exports.bar= bar;

// 👇👇👇 This will fail because `exports.bar` is not  a function
exports.foo = exports.bar();

It seems that Linaria is shaking the exported function and the final result is smth like this:

exports.foo = exports.bar();

Reproducible Demo

https://stackblitz.com/edit/node-ptrjmt

$ node using-babel.js

fixtureName passing
hello world

fixtureName failing
hello world

$ node using-shaker.js

fixtureName passing
hello world

fixtureName passing
hello world

TypeError: exports.bar is not a function
    at eval (/home/projects/node-ptrjmt/src/failing/foo.js:5:23)
    at eval (/home/projects/node-ptrjmt/src/failing/foo.js:6:3)
    at Proxy.<anonymous> (https://node-ptrjmt.jw.staticblitz.com/blitz.84452ea99b8c6a79e19cae2129beaf85d5da007c.js:8:17496)
    at __global_eval__ (https://node-ptrjmt.jw.staticblitz.com/blitz.84452ea99b8c6a79e19cae2129beaf85d5da007c.js:8:17707)
    at _0x23e309 (https://node-ptrjmt.jw.staticblitz.com/blitz.84452ea99b8c6a79e19cae2129beaf85d5da007c.js:11:175606)
    at Script.runInContext (https://node-ptrjmt.jw.staticblitz.com/blitz.84452ea99b8c6a79e19cae2129beaf85d5da007c.js:11:175161)
    at Script.runInContext (https://node-ptrjmt.jw.staticblitz.com/blitz.84452ea99b8c6a79e19cae2129beaf85d5da007c.js:6:401168)
    at Module.evaluate (/home/projects/node-ptrjmt/node_modules/@linaria/babel-preset/lib/module.js:293:12)
    at Proxy.Module.Object.assign.ensure (/home/projects/node-ptrjmt/node_modules/@linaria/babel-preset/lib/module.js:197:15)
    at eval (/home/projects/node-ptrjmt/src/failing/index.js:9:11)
@ling1726 ling1726 added bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided needs: triage 🏷 Issue needs to be checked and prioritized labels Jul 21, 2021
@github-actions github-actions bot removed the needs: triage 🏷 Issue needs to be checked and prioritized label Jul 21, 2021
@github-actions github-actions bot added needs: triage 🏷 Issue needs to be checked and prioritized and removed needs: triage 🏷 Issue needs to be checked and prioritized labels Jul 21, 2021
@Anber Anber self-assigned this Jul 21, 2021
@github-actions github-actions bot added the needs: triage 🏷 Issue needs to be checked and prioritized label Jul 21, 2021
@Anber Anber closed this as completed in 4bb7744 Jul 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided needs: triage 🏷 Issue needs to be checked and prioritized
Projects
None yet
Development

No branches or pull requests

2 participants