Skip to content

Commit

Permalink
integration: Remove lodash dependency (#1388)
Browse files Browse the repository at this point in the history
  • Loading branch information
askoufis authored Apr 29, 2024
1 parent 2232ef4 commit 6066606
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/afraid-planets-mix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@vanilla-extract/integration': patch
---

Remove `lodash` dependency
4 changes: 1 addition & 3 deletions packages/integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@
"eval": "0.1.8",
"find-up": "^5.0.0",
"javascript-stringify": "^2.0.1",
"lodash": "^4.17.21",
"mlly": "^1.4.2",
"outdent": "^0.8.0",
"vite": "^5.0.11",
"vite-node": "^1.2.0"
},
"devDependencies": {
"@types/babel__core": "^7.20.5",
"@types/lodash": "^4.14.168"
"@types/babel__core": "^7.20.5"
}
}
19 changes: 18 additions & 1 deletion packages/integration/src/processVanillaFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { FileScope, Adapter } from '@vanilla-extract/css';
import { transformCss } from '@vanilla-extract/css/transformCss';
import evalCode from 'eval';
import { stringify } from 'javascript-stringify';
import isPlainObject from 'lodash/isPlainObject';
import outdent from 'outdent';

import { hash } from './hash';
Expand All @@ -11,6 +10,24 @@ import type { IdentifierOption } from './types';

const originalNodeEnv = process.env.NODE_ENV;

function isPlainObject(value: unknown) {
if (typeof value !== 'object' || value === null) return false;

if (Object.prototype.toString.call(value) !== '[object Object]') return false;

const proto = Object.getPrototypeOf(value);
if (proto === null) return true;

const Ctor =
Object.prototype.hasOwnProperty.call(proto, 'constructor') &&
proto.constructor;
return (
typeof Ctor === 'function' &&
Ctor instanceof Ctor &&
Function.prototype.call(Ctor) === Function.prototype.call(value)
);
}

export function stringifyFileScope({
packageName,
filePath,
Expand Down
6 changes: 0 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6066606

Please sign in to comment.