Skip to content

Commit

Permalink
fix(babel): update cosmiconfig so linaria.config.cjs works (#1192)
Browse files Browse the repository at this point in the history
* fix(babel): update cosmiconfig so linaria.config.cjs works

This is important for projects that have type: module in package.json.

* fix(babel): remove @types/cosmiconfig since cosmiconfig now provides own types

Co-authored-by: Anton Evzhakov <anton@evz.name>
  • Loading branch information
agriffis and Anber committed Jan 19, 2023
1 parent cf1d661 commit 1d4d683
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .changeset/metal-hounds-push.md
@@ -0,0 +1,5 @@
---
'@linaria/babel-preset': patch
---

fix(babel): update cosmiconfig so linaria.config.cjs works
3 changes: 1 addition & 2 deletions packages/babel/package.json
Expand Up @@ -44,7 +44,7 @@
"@linaria/shaker": "workspace:^",
"@linaria/tags": "workspace:^",
"@linaria/utils": "workspace:^",
"cosmiconfig": "^5.1.0",
"cosmiconfig": "^8.0.0",
"find-up": "^5.0.0",
"source-map": "^0.7.3",
"stylis": "^3.5.4"
Expand All @@ -55,7 +55,6 @@
"@types/babel__helper-module-imports": "^7.18.0",
"@types/babel__template": "^7.4.1",
"@types/babel__traverse": "^7.17.1",
"@types/cosmiconfig": "^5.0.3",
"@types/dedent": "^0.7.0",
"@types/jest": "^28.1.0",
"@types/node": "^17.0.39",
Expand Down
@@ -1,4 +1,4 @@
import cosmiconfig from 'cosmiconfig';
import { cosmiconfigSync } from 'cosmiconfig';

import type { StrictOptions } from '@linaria/utils';

Expand All @@ -9,7 +9,7 @@ export type PluginOptions = StrictOptions & {
stage?: Stage;
};

const explorer = cosmiconfig('linaria');
const explorerSync = cosmiconfigSync('linaria');

const cache = new WeakMap<Partial<PluginOptions>, StrictOptions>();

Expand All @@ -24,8 +24,8 @@ export default function loadLinariaOptions(

const result =
configFile !== undefined
? explorer.loadSync(configFile)
: explorer.searchSync();
? explorerSync.load(configFile)
: explorerSync.search();

const options = {
displayName: false,
Expand Down
40 changes: 28 additions & 12 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 1d4d683

Please sign in to comment.