You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@sadortun@mtrezza I tried to replace require with import but ran into an issue with babel
I used import on EventEmitter.ts
import RNEventEmitter from 'react-native/Libraries/vendor/emitter/EventEmitter';
import { EventEmitter as NodeEventEmitter } from 'events';
let EventEmitter: any;
try {
if (process.env.PARSE_BUILD === 'react-native') {
EventEmitter = RNEventEmitter;
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
} else {
EventEmitter = NodeEventEmitter;
}
} catch (_) {
// EventEmitter unavailable
}
module.exports = EventEmitter;
export default EventEmitter;
Babel outputs to lib/node.js, as you can see the dead code has been eliminated but the unused import _EventEmitter didn't get removed. Are there any babel experts that would like to have a look?
var _EventEmitter = _interopRequireDefault(require("react-native/Libraries/vendor/emitter/EventEmitter"));
var _events = require("events");
var EventEmitter;
try {
EventEmitter = _events.EventEmitter;
} catch (_) {
// EventEmitter unavailable
}
module.exports = EventEmitter;
var _default = EventEmitter;
exports.default = _default;
New Feature / Enhancement Checklist
Current Limitation
Follow up of the discussion on #203
Currently, the SDK is imported globally, and the compilers cannot optimize the imports and remove unused code.
Firebase have a great explanation
https://firebase.googleblog.com/2021/08/the-new-firebase-js-sdk-now-ga.html?m=1
Feature / Enhancement Description
This would allow to reduce the compiled client side app by eliminating the unused code.
This would also allow to fix #203 by allowing to create instances the Parse library for those who need to interact with multiple Servers.
Example Use Case
Alternatives / Workarounds
3rd Party References
https://www.codingame.com/playgrounds/7463/tree-shaking-in-javascript-with-rollup
The text was updated successfully, but these errors were encountered: