diff --git a/CHANGELOG.md b/CHANGELOG.md index 81a942c..54d7ba4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +# v3.0.6 (Tue Apr 01 2025) + +#### 🐛 Bug Fix + +- Avoid buggy getProjectRoot() [#14](https://github.com/storybookjs/addon-webpack5-compiler-babel/pull/14) ([@ddadamhooper](https://github.com/ddadamhooper) [@valentinpalkovic](https://github.com/valentinpalkovic)) + +#### Authors: 2 + +- Adam Hooper ([@ddadamhooper](https://github.com/ddadamhooper)) +- Valentin Palkovic ([@valentinpalkovic](https://github.com/valentinpalkovic)) + +--- + # v3.0.5 (Mon Dec 30 2024) #### 🐛 Bug Fix diff --git a/package.json b/package.json index 1a938f0..75e6e95 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@storybook/addon-webpack5-compiler-babel", - "version": "3.0.5", + "version": "3.0.6", "type": "module", "description": "Adds babel as a Webpack5 compiler to Storybook", "keywords": [ @@ -63,7 +63,6 @@ "@storybook/types": "8.4.7", "auto": "^11.3.0", "find-cache-dir": "^5.0.0", - "find-up": "^7.0.0", "tsup": "^8.3.5", "typescript": "^5.7.2", "webpack": "^5.97.1" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a1cd2f1..f1f0598 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -33,9 +33,6 @@ importers: find-cache-dir: specifier: ^5.0.0 version: 5.0.0 - find-up: - specifier: ^7.0.0 - version: 7.0.0 tsup: specifier: ^8.3.5 version: 8.3.5(typescript@5.7.2) @@ -1102,10 +1099,6 @@ packages: resolution: {integrity: sha512-v2ZsoEuVHYy8ZIlYqwPe/39Cy+cFDzp4dXPaxNvkEuouymu+2Jbz0PxpKarJHYJTmv2HWT3O382qY8l4jMWthw==, tarball: https://registry.npmjs.org/find-up/-/find-up-6.3.0.tgz} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - find-up@7.0.0: - resolution: {integrity: sha512-YyZM99iHrqLKjmt4LJDj58KI+fYyufRLBSYcqycxf//KpBk9FoewoGX0450m9nB44qrZnovzC2oeP5hUibxc/g==, tarball: https://registry.npmjs.org/find-up/-/find-up-7.0.0.tgz} - engines: {node: '>=18'} - for-each@0.3.3: resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==, tarball: https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz} @@ -1957,10 +1950,6 @@ packages: undici-types@6.20.0: resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==, tarball: https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz} - unicorn-magic@0.1.0: - resolution: {integrity: sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ==, tarball: https://registry.npmjs.org/unicorn-magic/-/unicorn-magic-0.1.0.tgz} - engines: {node: '>=18'} - universal-user-agent@6.0.1: resolution: {integrity: sha512-yCzhz6FN2wU1NiiQRogkTQszlQSlpWaw8SvVegAc+bDxbzHgh1vX8uIe8OYyMH6DwH+sdTJsgMl36+mSMdRJIQ==, tarball: https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.1.tgz} @@ -3215,12 +3204,6 @@ snapshots: locate-path: 7.2.0 path-exists: 5.0.0 - find-up@7.0.0: - dependencies: - locate-path: 7.2.0 - path-exists: 5.0.0 - unicorn-magic: 0.1.0 - for-each@0.3.3: dependencies: is-callable: 1.2.7 @@ -3996,8 +3979,6 @@ snapshots: undici-types@6.20.0: {} - unicorn-magic@0.1.0: {} - universal-user-agent@6.0.1: {} update-browserslist-db@1.1.1(browserslist@4.24.3): diff --git a/src/preset.ts b/src/preset.ts index 3d967b2..2b12d64 100644 --- a/src/preset.ts +++ b/src/preset.ts @@ -1,6 +1,6 @@ import type { Options } from "@storybook/types"; import type { Configuration } from "webpack"; -import { getProjectRoot, resolvePathInStorybookCache } from "./utils.js"; +import { resolvePathInStorybookCache } from "./utils.js"; const virtualModuleFiles = [ /storybook-config-entry\.js$/, @@ -32,7 +32,6 @@ export const webpackFinal = async (config: Configuration, options: Options) => { }, }, ], - include: [getProjectRoot()], exclude: [/node_modules/, ...virtualModuleFiles], }, ], diff --git a/src/utils.ts b/src/utils.ts index 3e72757..252025d 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,7 +1,6 @@ import { join } from "node:path"; import findCacheDirectory from "find-cache-dir"; -import { findUpSync } from "find-up"; /** * Get the path of the file or directory with input name inside the Storybook cache directory: @@ -21,59 +20,3 @@ export function resolvePathInStorybookCache( return join(cacheDirectory, sub, fileOrDirectoryName); } - -/** - * @returns {string} The root directory of the project - */ -export const getProjectRoot = () => { - let result: string | undefined; - // Allow manual override in cases where auto-detect doesn't work - // biome-ignore lint/complexity/useLiteralKeys: Ignore - if (process.env["STORYBOOK_PROJECT_ROOT"]) { - // biome-ignore lint/complexity/useLiteralKeys: Ignore - return process.env["STORYBOOK_PROJECT_ROOT"]; - } - - try { - const found = findUpSync(".git", { type: "directory" }); - if (found) { - result = join(found, ".."); - } - } catch (e) { - // - } - try { - const found = findUpSync(".svn", { type: "directory" }); - if (found) { - result = result || join(found, ".."); - } - } catch (e) { - // - } - try { - const found = findUpSync(".hg", { type: "directory" }); - if (found) { - result = result || join(found, ".."); - } - } catch (e) { - // - } - - try { - const splitDirname = __dirname.split("node_modules"); - result = result || (splitDirname.length >= 2 ? splitDirname[0] : undefined); - } catch (e) { - // - } - - try { - const found = findUpSync(".yarn", { type: "directory" }); - if (found) { - result = result || join(found, ".."); - } - } catch (e) { - // - } - - return result || process.cwd(); -};