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: named exports are removed #800
Comments
As I see, technically it should be handled in linaria/packages/shaker/src/langs/core.ts Lines 312 to 324 in 45e5de0
If I naively do: if (declaration && this.graph.importAliases.has(declaration)) {
// It is. We can remember what exactly we use from it.
const source = this.graph.importAliases.get(declaration)!;
this.graph.imports.get(source)!.push(node.property);
- }
+ } else {
+ this.graph.imports.set('./foo', [node.property]);
+ } It's passing:
The problem is that |
Thank you @layershifter for such a great issue! PS Migration to |
[I hope] fixed in |
If you replace export with |
The original issue is solved, but as @weyheyhey mention Babel transforms it too: "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _foo = require("./foo");
Object.keys(_foo).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _foo[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _foo[key];
}
});
}); |
Damn, that code looks absolutely unshakable… Anyway, a new issue would be cool. |
In case of multiple
|
@Anber @weyheyhey I created #808 to track it. Honestly, don't have a good idea how to handle it. |
Environment
@linaria/babel-preset@3.0.0-beta.7
,@linaria/shaker@3.0.0-beta.7
Description
Hello folks!
I am using
@linaria/babel-preset
&@linaria/shaker
for our CSS-in-JS and it looks that we spot an issue, please check "Reproducible Demo" section first.Failing fixture contains named exports (
foo
,bar
) and there is an issue with resolving them (checkusing-shaker.js
). For comparison I added evaluation with@babel/register
(checkusing-babel.js
).I followed debugging guide and dumped output.
log.txt
According to the output:
shaker
is evaluated forsrc/failing/index.js
and removes unused code properlysrc/failing/foo.js
shaker
is called withexports: default
, this results in removing all code fromsrc/failing/foo.js
Reproducible Demo
https://stackblitz.com/edit/node-yfjhdp
you can either download project or execute code built-in terminal
$ node using-babel.js
$ node using-shaker.js
The text was updated successfully, but these errors were encountered: