@storybook/addon-svelte-csf 4.0.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import dedent from 'dedent';
|
|
2
1
|
import { extractStories } from './extract-stories.js';
|
|
3
2
|
import { fileURLToPath } from 'url';
|
|
4
3
|
import { readFileSync } from 'fs';
|
|
5
4
|
const parser = fileURLToPath(new URL('./collect-stories.js', import.meta.url))
|
|
6
|
-
.replace(/\\/g,
|
|
5
|
+
.replace(/\\/g, '/'); // For Windows paths;
|
|
7
6
|
// From https://github.com/sveltejs/svelte/blob/8db3e8d0297e052556f0b6dde310ef6e197b8d18/src/compiler/compile/utils/get_name_from_filename.ts
|
|
8
7
|
// Copied because it is not exported from the compiler
|
|
9
8
|
export function getNameFromFilename(filename) {
|
|
@@ -44,9 +43,7 @@ function transformSvelteStories(code) {
|
|
|
44
43
|
.map(([id]) => `export const ${id} = __storiesMetaData.stories[${JSON.stringify(id)}]`)
|
|
45
44
|
.join('\n');
|
|
46
45
|
const codeWithoutDefaultExport = code.replace('export default ', '//export default');
|
|
47
|
-
|
|
48
|
-
// @ts-ignore
|
|
49
|
-
return dedent `${codeWithoutDefaultExport}
|
|
46
|
+
return `${codeWithoutDefaultExport}
|
|
50
47
|
const { default: parser } = require('${parser}');
|
|
51
48
|
const __storiesMetaData = parser(${componentName}, ${JSON.stringify(storiesDef)});
|
|
52
49
|
export default __storiesMetaData.meta;
|