Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"devDependencies": {
"@types/eslint": "^6.1.2",
"@types/fs-extra": "^9.0.1",
"@types/lodash": "^4.14.161",
"@types/node": "^14.11.1",
"@types/react": "^16.9.11",
"@types/rollup-plugin-json": "^3.0.2",
Expand Down
3 changes: 2 additions & 1 deletion src/babelPluginTsdx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export const isTruthy = (obj?: any) => {
return obj.constructor !== Object || Object.keys(obj).length > 0;
};

const replacements = [{ original: 'lodash', replacement: 'lodash-es' }];
// replace lodash with lodash-es, but not lodash/fp
const replacements = [{ original: 'lodash(?!/fp)', replacement: 'lodash-es' }];

export const mergeConfigItems = (type: any, ...configItemsToMerge: any[]) => {
const mergedItems: any[] = [];
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/fixtures/build-default/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import './syntax/jsx-import/JSX-import-JSX';
import './syntax/async';
export { testGenerator } from './syntax/generator';

export { kebabCase } from 'lodash';
export { merge, mergeAll } from 'lodash/fp';

export { foo } from './foo';

export const sum = (a: number, b: number) => {
Expand Down
24 changes: 24 additions & 0 deletions test/e2e/tsdx-build-default.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,30 @@ describe('tsdx build :: zero-config defaults', () => {
expect(matched).toBeFalsy();
});

it('should use lodash for the CJS build', () => {
const output = execWithCache('node ../dist/index.js build');
expect(output.code).toBe(0);

const matched = grep(/lodash/, ['dist/build-default.cjs.*.js']);
expect(matched).toBeTruthy();
});

it('should use lodash-es for the ESM build', () => {
const output = execWithCache('node ../dist/index.js build');
expect(output.code).toBe(0);

const matched = grep(/lodash-es/, ['dist/build-default.esm.js']);
expect(matched).toBeTruthy();
});

it("shouldn't replace lodash/fp", () => {
const output = execWithCache('node ../dist/index.js build');
expect(output.code).toBe(0);

const matched = grep(/lodash\/fp/, ['dist/build-default.*.js']);
expect(matched).toBeTruthy();
});

it('should clean the dist directory before rebuilding', () => {
let output = execWithCache('node ../dist/index.js build');
expect(output.code).toBe(0);
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,11 @@
dependencies:
"@types/node" "*"

"@types/lodash@^4.14.161":
version "4.14.161"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.161.tgz#a21ca0777dabc6e4f44f3d07f37b765f54188b18"
integrity sha512-EP6O3Jkr7bXvZZSZYlsgt5DIjiGr0dXP1/jVEwVLTFgg0d+3lWVQkRavYVQszV7dYUwvg0B8R0MBDpcmXg7XIA==

"@types/minimatch@*", "@types/minimatch@^3.0.3":
version "3.0.3"
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
Expand Down