Skip to content

Commit 80b8dae

Browse files
authored
ref: update knip (#92249)
it now correctly identifies custom loaders set in resolveLoader.alias, so we don't need them as a manual entry point anymore
1 parent 73394f8 commit 80b8dae

File tree

6 files changed

+21
-20
lines changed

6 files changed

+21
-20
lines changed

knip.config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ const testingEntryPoints = [
3333
const storyBookEntryPoints = [
3434
// our storybook implementation is here
3535
'static/app/stories/storyBook.tsx',
36-
// custom webpack loaders for stories
37-
'static/app/stories/*loader.ts',
3836
// we have some stories in mdx format
3937
'static/app/**/*.mdx',
4038
];

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@
229229
"jest-environment-jsdom": "29.7.0",
230230
"jest-fail-on-console": "3.3.0",
231231
"jest-junit": "16.0.0",
232-
"knip": "^5.57.0",
232+
"knip": "^5.58.0",
233233
"postcss-styled-syntax": "0.7.0",
234234
"react-refresh": "0.16.0",
235235
"stylelint": "16.10.0",

static/app/stories/noop-type-loader.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

static/app/stories/type-loader.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type {LoaderContext} from 'webpack';
88
* @param {string} source source file as string
99
* @returns {void}
1010
*/
11-
export default function typeloader(this: LoaderContext<any>, _source: string) {
11+
function prodTypeloader(this: LoaderContext<any>, _source: string) {
1212
const callback = this.async();
1313
const entries = docgen.parse(this.resourcePath, {
1414
shouldExtractLiteralValuesFromEnum: true,
@@ -35,3 +35,17 @@ export default function typeloader(this: LoaderContext<any>, _source: string) {
3535
);
3636
return callback(null, `export default ${JSON.stringify(typeIndex)}`);
3737
}
38+
39+
function noopTypeLoader(this: LoaderContext<any>, _source: string) {
40+
const callback = this.async();
41+
return callback(null, 'export default {}');
42+
}
43+
44+
export default function typeLoader(this: LoaderContext<any>, _source: string) {
45+
const STORYBOOK_TYPES =
46+
Boolean(process.env.STORYBOOK_TYPES) || process.env.node_ENV === 'production';
47+
48+
return STORYBOOK_TYPES
49+
? prodTypeloader.call(this, _source)
50+
: noopTypeLoader.call(this, _source);
51+
}

webpack.config.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ const SHOULD_FORK_TS = DEV_MODE && !env.NO_TS_FORK; // Do not run fork-ts plugin
7777
const SHOULD_HOT_MODULE_RELOAD = DEV_MODE && !!env.SENTRY_UI_HOT_RELOAD;
7878
const SHOULD_ADD_RSDOCTOR = Boolean(env.RSDOCTOR);
7979

80-
// Storybook related flag configuration
81-
const STORYBOOK_TYPES = Boolean(env.STORYBOOK_TYPES) || IS_PRODUCTION;
82-
8380
// Deploy previews are built using vercel. We can check if we're in vercel's
8481
// build process by checking the existence of the PULL_REQUEST env var.
8582
const DEPLOY_PREVIEW_CONFIG = IS_DEPLOY_PREVIEW && {
@@ -412,9 +409,7 @@ const appConfig: webpack.Configuration = {
412409

413410
resolveLoader: {
414411
alias: {
415-
'type-loader': STORYBOOK_TYPES
416-
? path.resolve(__dirname, 'static/app/stories/type-loader.ts')
417-
: path.resolve(__dirname, 'static/app/stories/noop-type-loader.ts'),
412+
'type-loader': path.resolve(__dirname, 'static/app/stories/type-loader.ts'),
418413
},
419414
},
420415

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9463,10 +9463,10 @@ kleur@^3.0.3:
94639463
resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e"
94649464
integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==
94659465

9466-
knip@^5.57.0:
9467-
version "5.57.0"
9468-
resolved "https://registry.yarnpkg.com/knip/-/knip-5.57.0.tgz#705ec5472a8108cf163b68d83fe483ddf61e242b"
9469-
integrity sha512-3i2neotCfFWOEGByzz8kzSFePZahelhwZfHXT5SM9FlpMxzN1PE8wV+M65Sl+itd2Z+v7FBXeVd96YLwXnviGg==
9466+
knip@^5.58.0:
9467+
version "5.58.0"
9468+
resolved "https://registry.yarnpkg.com/knip/-/knip-5.58.0.tgz#54fe4b71e6ddb0b060de3c2cf45ff4fb68e5373b"
9469+
integrity sha512-U3+ADL9mylwia7bU85CYeHSdMI7DIpaCzH37NZ8rru/dgq56iyiS0oTELhfNaCYu+TcRyuijU2YQf9o0zUGA5w==
94709470
dependencies:
94719471
"@nodelib/fs.walk" "^1.2.3"
94729472
fast-glob "^3.3.3"

0 commit comments

Comments
 (0)