Comments (4)
Hi @usman-subhani!
Can you post what the transpiled code looks like?
from babel-plugin-lodash.
Hey @jdalton, sure. This is the transpiled code with the plugin
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "test", function() { return test; });
class test {
constructor() {
this._ = undefined; // lodash is replaced with 'undefined' here
}
someMethod() {
const value = this._.get({
a: 1
}, 'a'); // error thrown here because this._ is undefined
}
}
and this is the code after removing the plugin
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "test", function() { return test; });
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_0__);
class test {
constructor() {
this._ = lodash__WEBPACK_IMPORTED_MODULE_0___default.a; // lodash is imported and set here
}
someMethod() {
const value = this._.get({
a: 1
}, 'a'); // works fine now
}
}
This is the .babelrc config
{
"presets": [
"@babel/preset-react",
["@babel/preset-env", {
"targets": {
"chrome": "72",
"firefox": "64",
"opera": "50",
"node": "current"
}
}]
],
"plugins": ["lodash", "@babel/plugin-transform-runtime"]
}
I have v3.3.4 of babel-plugin lodash
from babel-plugin-lodash.
Have the same issue: lodash
is being replaced with undefined
. If I disable babel-plugin-lodash
, the reference is preserved.
from babel-plugin-lodash.
Have the same issue:
lodash
is being replaced withundefined
. If I disablebabel-plugin-lodash
, the reference is preserved.
same issue, is there a solution now?
from babel-plugin-lodash.
Related Issues (20)
- Babel 7 support HOT 2
- Issues while using with Babel 7 and Typescript plugin HOT 4
- Error: Couldn't find preset "@babel/env" relative to directory HOT 1
- Bundle size not reduced when I make a production build HOT 1
- Lazy evaluation not working for fp.flow HOT 2
- cccccckiekunkdevvibtrjecnjlngvkhvhdvdbkgcgbg
- 'unionBy' do not accept property name as iteratee HOT 3
- Plugin adds weight to project HOT 3
- Bundle contains many lodash functions HOT 5
- tips
- The 'react-router-dom' method `useLocation` is not a known module.
- lodash.min.js is not removed from the bundle HOT 2
- Do you have plan to support vitejs? HOT 1
- Import with extensions
- lodash and pnpm
- Is this plugin still relevant? HOT 4
- Error: "Cannot read property 'has' of undefined" after glob update v7.2.0 to v7.2.2
- use `module:`
- `isModuleDeclaration` has been deprecated HOT 14
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-lodash.