Skip to content

Commit

Permalink
defineConfig function and a @crackle/cli/config entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
mrm007 committed Jun 23, 2023
1 parent a955aa2 commit 64a68be
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 6 deletions.
14 changes: 14 additions & 0 deletions .changeset/cli-schools-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
'@crackle/cli': patch
---

Re-export `CrackleConfig` and `defineConfig` so that they can be used in `crackle.config.ts` without adding `@crackle/core` as a dependency

```ts
// crackle.config.ts
import { defineConfig } from '@crackle/cli/config';

export default defineConfig({
// ...
});
```
5 changes: 5 additions & 0 deletions .changeset/core-falcons-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@crackle/core': patch
---

Export a `defineConfig` function to simplify typing the config object
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ packages/babel-plugin-remove-exports/dist
# end managed by crackle

# managed by crackle
packages/cli/config
packages/cli/dist
# end managed by crackle

Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ packages/babel-plugin-remove-exports/dist
# end managed by crackle

# managed by crackle
packages/cli/config
packages/cli/dist
# end managed by crackle

Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,18 @@ Here's how to specify a custom configuration file:

```ts
// crackle.config.ts
import type { CrackleConfig } from '@crackle/core';
import { defineConfig } from '@crackle/cli/config';

export default defineConfig({
// ...
});
```

or

```ts
// crackle.config.ts
import type { CrackleConfig } from '@crackle/cli/config';

export default {
// ...
Expand Down
2 changes: 1 addition & 1 deletion docs/esm-reconciliation.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Crackle can be instructed to handle this via the `reconcileDependencies` option,

```ts
// crackle.config.ts
import type { CrackleConfig } from '@crackle/core';
import type { CrackleConfig } from '@crackle/cli';

export default {
reconcileDependencies: {
Expand Down
2 changes: 1 addition & 1 deletion fixtures/esm-compat/crackle.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CrackleConfig } from '@crackle/core';
import type { CrackleConfig } from '@crackle/cli/config';

export default {
reconcileDependencies: {
Expand Down
1 change: 1 addition & 0 deletions packages/cli/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# managed by crackle
/config
/dist
# end managed by crackle
10 changes: 8 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
},
"./config": {
"types": "./dist/config.d.ts",
"import": "./dist/config.mjs",
"require": "./dist/config.cjs"
},
"./package.json": "./package.json"
},
"main": "./dist/index.cjs",
Expand All @@ -20,11 +25,12 @@
"files": [
"CHANGELOG.md",
"bin.js",
"config",
"dist"
],
"scripts": {
"dev": "crackle dev",
"build": "crackle package"
"build": "crackle package",
"dev": "crackle dev"
},
"dependencies": {
"@crackle/core": "^0.26.0",
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/entries/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { type CrackleConfig, defineConfig } from '@crackle/core';
7 changes: 6 additions & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
export type { PartialConfig as CrackleConfig } from './config';
import type { PartialConfig as CrackleConfig } from './config';

export type { AppShell, CrackleServer } from './types';

export type { CrackleConfig };

export const defineConfig = (config: CrackleConfig) => config;

0 comments on commit 64a68be

Please sign in to comment.