
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
lodash-ts-imports-loader
Advanced tools
Transpiles ES6 lodash imports into typescript imports to help with tree-shaking
A webpack preloader which transpiles ES6 lodash imports into typescript imports to help with tree-shaking.
Basically transpiles from ES6 syntax:
import { debounce } from 'lodash';
into typescript syntax:
import debounce = require('lodash/debounce');
before the source code is being taken through the typescript compiler.
This way webpack 2 will be able to only include the code that's being actually used.
$ npm install lodash-ts-imports-loader --save-dev
In your webpack.config.js
add the lodash-ts-imports-loader
preloader:
// ...
module: {
rules: [
{
test: /\.ts$/,
loader: 'lodash-ts-imports-loader',
exclude: /node_modules/,
enforce: "pre"
},
// ...
],
// ...
}
// ...
Now somewhere in your main.ts
typescript file add an ES6 import for lodash:
import { debounce } from 'lodash';
// make sure you have this line as well otherwise you're not using the import member
// and the lodash code will not be included in the bundle
console.log(debounce);
run webpack bundling and check your bundle size.
Update the code to:
import { debounce, zip } from 'lodash';
// make sure you have this lines as well otherwise you're not using the import members
// and the lodash code will not be included in the bundle
console.log(debounce);
console.log(zip);
run webpack bundling and check your bundle size.
This time the bundle size should be larger.
NPM:
https://www.npmjs.com/package/lodash-ts-imports-loader
GITHUB:
https://github.com/efidiles/lodash-ts-imports-loader.git
Eduard Fidiles
[jump to TOC]
Released under the MIT license.
Copyright © 2016, Eduard Fidiles
FAQs
Transpiles ES6 lodash imports into typescript imports to help with tree-shaking
The npm package lodash-ts-imports-loader receives a total of 4 weekly downloads. As such, lodash-ts-imports-loader popularity was classified as not popular.
We found that lodash-ts-imports-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.