brute force fix for ngResource query param in path
MODIFY
bin-src/lib/getDependentStoryFiles.test.ts
bin-src/lib/getDependentStoryFiles.test.ts
@@ -185,6 +185,38 @@ describe('getDependentStoryFiles', () => {
});
});
+ it('detects indirect changes to CSF files, angular css resource', async () => {
+ const changedFiles = ['src/foo.css'];
+ const modules = [
+ {
+ id: null,
+ name: './src/foo.css?ngResource ',
+ reasons: [{ moduleName: './src/foo.component.ts' }],
+ },
+ {
+ id: './src/foo.component.ts',
+ name: './src/foo.component.ts + 1 modules',
+ modules: [{ name: './src/foo.component.ts' }, { name: './src/foo.css?ngResource' }],
+ reasons: [{ moduleName: './src/foo.stories.ts' }],
+ },
+ {
+ id: './src/foo.stories.ts',
+ name: './src/foo.stories.ts',
+ reasons: [{ moduleName: CSF_GLOB }],
+ },
+ {
+ id: CSF_GLOB,
+ name: CSF_GLOB,
+ reasons: [{ moduleName: './.storybook/generated-stories-entry.js' }],
+ },
+ ];
+ const ctx = getContext();
+ const res = await getDependentStoryFiles(ctx, { modules }, statsPath, changedFiles);
+ expect(res).toEqual({
+ './src/foo.stories.ts': ['src/foo.stories.ts'],
+ });
+ });
+
it('detects indirect changes to CSF files in a single module chunk', async () => {
const changedFiles = ['src/foo.js'];
const modules = [

MODIFY
bin-src/lib/getDependentStoryFiles.ts
bin-src/lib/getDependentStoryFiles.ts
@@ -97,13 +97,18 @@ export async function getDependentStoryFiles(
stats.modules
.filter((mod) => isUserModule(mod))
.forEach((mod) => {
- const normalizedName = normalize(mod.name);
+ let { name } = mod;
+ if (mod.name.includes('?ngResource')) {
+ [name] = mod.name.split('?');
+ }
+ const normalizedName = normalize(name);
modulesByName[normalizedName] = mod;
namesById[mod.id] = normalizedName;
if (mod.modules) {
mod.modules.forEach((m) => {
- modulesByName[normalize(m.name)] = mod;
+ modulesByName[normalize(m.name.includes('?ngResource') ? m.name.split('?')[0] : m.name)] =
+ mod;
});
}

brute force fix for ngResource query param in path