Skip to content
This repository was archived by the owner on Oct 28, 2023. It is now read-only.
This repository was archived by the owner on Oct 28, 2023. It is now read-only.

Support CRACO's new cosmiconfig and TS configuration formatsΒ #11

Open
@elektronik2k5

Description

@elektronik2k5

Hello and thanks for maintaining this plugin! πŸ™‡πŸ»β€β™€οΈ

CRACO@6.4 added support for cosmiconfig based configuration, as well as TS based configuration. Currently this plugin fails to find a craco.config.ts file with this error:

ERR! Error: Cannot find module '/path/to/project/craco.config.js'
ERR! Require stack:
ERR! - /path/to/project/node_modules/storybook-preset-craco/index.js
ERR! - /path/to/project/node_modules/@storybook/core-common/dist/cjs/presets.js
ERR! - /path/to/project/node_modules/@storybook/core-common/dist/cjs/index.js
ERR! - /path/to/project/node_modules/@storybook/core-server/dist/cjs/index.js
ERR! - /path/to/project/node_modules/@storybook/core/dist/cjs/server.js
ERR! - /path/to/project/node_modules/@storybook/core/server.js
ERR! - /path/to/project/node_modules/@storybook/react/dist/cjs/server/index.js
ERR! - /path/to/project/node_modules/@storybook/react/bin/index.js
ERR!     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
ERR!     at Function.Module._load (node:internal/modules/cjs/loader:778:27)
ERR!     at Module.require (node:internal/modules/cjs/loader:1005:19)
ERR!     at require (node:internal/modules/cjs/helpers:102:18)
ERR!     at Object.webpack (/path/to/project/node_modules/storybook-preset-craco/index.js:57:23)
ERR!     at /path/to/project/node_modules/@storybook/core-common/dist/cjs/presets.js:274:28
ERR!     at async Object.start (/path/to/project/node_modules/@storybook/builder-webpack4/dist/cjs/index.js:95:16)
ERR!     at async Promise.all (index 0)
ERR!     at async storybookDevServer (/path/to/project/node_modules/@storybook/core-server/dist/cjs/dev-server.js:123:28)
ERR!     at async buildDevStandalone (/path/to/project/node_modules/@storybook/core-server/dist/cjs/build-dev.js:112:31)
ERR!     at async buildDev (/path/to/project/node_modules/@storybook/core-server/dist/cjs/build-dev.js:154:5)
ERR!  Error: Cannot find module '/path/to/project/craco.config.js'
ERR! Require stack:
ERR! - /path/to/project/node_modules/storybook-preset-craco/index.js
ERR! - /path/to/project/node_modules/@storybook/core-common/dist/cjs/presets.js
ERR! - /path/to/project/node_modules/@storybook/core-common/dist/cjs/index.js
ERR! - /path/to/project/node_modules/@storybook/core-server/dist/cjs/index.js
ERR! - /path/to/project/node_modules/@storybook/core/dist/cjs/server.js
ERR! - /path/to/project/node_modules/@storybook/core/server.js
ERR! - /path/to/project/node_modules/@storybook/react/dist/cjs/server/index.js
ERR! - /path/to/project/node_modules/@storybook/react/bin/index.js
ERR!     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
ERR!     at Function.Module._load (node:internal/modules/cjs/loader:778:27)
ERR!     at Module.require (node:internal/modules/cjs/loader:1005:19)
ERR!     at require (node:internal/modules/cjs/helpers:102:18)
ERR!     at Object.webpack (/path/to/project/node_modules/storybook-preset-craco/index.js:57:23)
ERR!     at /path/to/project/node_modules/@storybook/core-common/dist/cjs/presets.js:274:28
ERR!     at async Object.start (/path/to/project/node_modules/@storybook/builder-webpack4/dist/cjs/index.js:95:16)
ERR!     at async Promise.all (index 0)
ERR!     at async storybookDevServer (/path/to/project/node_modules/@storybook/core-server/dist/cjs/dev-server.js:123:28)
ERR!     at async buildDevStandalone (/path/to/project/node_modules/@storybook/core-server/dist/cjs/build-dev.js:112:31)
ERR!     at async buildDev (/path/to/project/node_modules/@storybook/core-server/dist/cjs/build-dev.js:154:5) {
ERR!   code: 'MODULE_NOT_FOUND',
ERR!   requireStack: [
ERR!     '/path/to/project/node_modules/storybook-preset-craco/index.js',
ERR!     '/path/to/project/node_modules/@storybook/core-common/dist/cjs/presets.js',
ERR!     '/path/to/project/node_modules/@storybook/core-common/dist/cjs/index.js',
ERR!     '/path/to/project/node_modules/@storybook/core-server/dist/cjs/index.js',
ERR!     '/path/to/project/node_modules/@storybook/core/dist/cjs/server.js',
ERR!     '/path/to/project/node_modules/@storybook/core/server.js',
ERR!     '/path/to/project/node_modules/@storybook/react/dist/cjs/server/index.js',
ERR!     '/path/to/project/node_modules/@storybook/react/bin/index.js'
ERR!   ]
ERR! }

Providing an options.cracoConfigFile for non native node files (TS) won't work either, of course.

I think the code to supporting this functionality is mostly implemented in the original CRACO PR.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions