Comments (6)
@evan-scott-zocdoc If you want to use it on webpack's output I guess you are using it on application+lib bundle, due to the fact that it's probably a much bigger codebase than a single library I advise caution - but ofc you probably know that this is somewhat a little bit dangerous transform.
Tree-shaking is prevented mainly in cases of:
- function calls, heavy fp usage (compose, curried functions etc) - latter should be quite safely fixed by this plugin
- static properties, most common use case being classes - this one is out of scope of this plugin, I'm working (nearly finished) on the PR to babel which should improve the situation for those (will be available in future babel@7-betas)
And ofc enabling ModuleConcatenationPlugin
can improve things quite a lot (worth noting this for other readers, you probably already know what :))
from babel-plugin-annotate-pure-calls.
1st issue reported by the community member 🎉
I guess leadingComments property is not set on the node (speaking totally from my gut, im in a travel on a mobile, havent checked the source code). I can guard against that ofc, but it's pretty interesting why this is not set. Thought it's always there, I remember someone mentioning something about similar case on Babel's Slack - need to dig into this.
Could you paste in the minimal repro file? Would love to examine how Babel handles it and of course to write a test for this.
from babel-plugin-annotate-pure-calls.
I think this would be enough?
const test = 'hello world';
/* eslint-disable babel/new-cap */
export default test;
from babel-plugin-annotate-pure-calls.
Fixed on the master (targeting babel@6) and released. Didn't make any changes to the babel-7
branch, because this deserves a fix upstream in babel
itself IMHO. The situation should be normalized, even babel's typings does not make those fields optional.
Thanks for the report! Would love to hear how (where?) do you use the plugin.
from babel-plugin-annotate-pure-calls.
Thanks @Andarist, I'll try out the change.
I'm attempting to use this plugin as a way of overcoming the fact that webpack 3's treeshaking is broken.
from babel-plugin-annotate-pure-calls.
And ofc enabling ModuleConcatenationPlugin can improve things quite a lot
Definitely, we've been using that for a few months.
The specific target I'm trying to treeshake more efficiently is the so-called "re-export file", e.g. an index file that imports from many other files and re-exports under different names. In many cases, a person will import that index and destructure out a specific export, but all the other exports end up coming along for the ride anyway.
// index.js
export { default as a } from './a';
export { default as b } from './b';
export { default as c } from './c';
// some other file
import { a } from 'index.js';
// ideally b and c would be treeshaken
from babel-plugin-annotate-pure-calls.
Related Issues (11)
- Investigate called CallExpressions situation HOT 1
- Provide ignore/include filenames option
- Upgrade peer dependency to @babel/core 7 HOT 1
- Review HOT 3
- Optimize ArrowFunctionExpression with implicit return
- Consider adding always effectful built-ins + configuration for them
- Skip callable expressions used as callees
- Provide option to customize annotation of top level IIFEs
- Provide option to annotate all callable expressions
- Provide option to annotate only whitelisted identifiers
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from babel-plugin-annotate-pure-calls.