From 261b3bb0f8e1296827636c0ecfa77c724beeee38 Mon Sep 17 00:00:00 2001 From: 42shadow42 <42shadow42@gmail.com> Date: Sat, 18 Mar 2023 14:51:40 -0500 Subject: [PATCH 1/4] Raw support for mjs,jsx, and tsx files --- code/lib/builder-webpack5/src/preview/babel-loader-preview.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/code/lib/builder-webpack5/src/preview/babel-loader-preview.ts b/code/lib/builder-webpack5/src/preview/babel-loader-preview.ts index 7728ceef58c6..8bdb93b09495 100644 --- a/code/lib/builder-webpack5/src/preview/babel-loader-preview.ts +++ b/code/lib/builder-webpack5/src/preview/babel-loader-preview.ts @@ -10,6 +10,7 @@ export const createBabelLoader = (options: any, typescriptOptions: TypescriptOpt options, }, ], + resourceQuery: { not: [/raw/] }, include: [getProjectRoot()], exclude: /node_modules/, }; From 5039b3b757418ad381b2e0950b0b6e148d850f22 Mon Sep 17 00:00:00 2001 From: Nathaniel Hunter <42shadow42@gmail.com> Date: Sat, 18 Mar 2023 16:39:52 -0500 Subject: [PATCH 2/4] Added stories to demonstrate the fix --- .../template/stories/stories-mdx/RawSource.jsx | 7 +++++++ .../stories/stories-mdx/raw-source.non-stories.js | 15 +++++++++++++++ .../stories/stories-mdx/raw-source.stories.mdx | 9 +++++++++ 3 files changed, 31 insertions(+) create mode 100644 code/addons/docs/template/stories/stories-mdx/RawSource.jsx create mode 100644 code/addons/docs/template/stories/stories-mdx/raw-source.non-stories.js create mode 100644 code/addons/docs/template/stories/stories-mdx/raw-source.stories.mdx diff --git a/code/addons/docs/template/stories/stories-mdx/RawSource.jsx b/code/addons/docs/template/stories/stories-mdx/RawSource.jsx new file mode 100644 index 000000000000..41cee7b217f1 --- /dev/null +++ b/code/addons/docs/template/stories/stories-mdx/RawSource.jsx @@ -0,0 +1,7 @@ +import React, { Fragment } from 'react'; + +export const MY_VALUE_I_WANT_TO_SHOW_IN_STORY = 'Hello World!'; + +export const RawSource = () => { + return {MY_VALUE_I_WANT_TO_SHOW_IN_STORY}; +}; diff --git a/code/addons/docs/template/stories/stories-mdx/raw-source.non-stories.js b/code/addons/docs/template/stories/stories-mdx/raw-source.non-stories.js new file mode 100644 index 000000000000..8391ae907795 --- /dev/null +++ b/code/addons/docs/template/stories/stories-mdx/raw-source.non-stories.js @@ -0,0 +1,15 @@ +import { RawSource as RawSourceComponent } from './RawSource.jsx'; +// eslint-disable-next-line import/no-unresolved +import RawSourceCode from './RawSource.jsx?raw'; + +export const RawSource = RawSourceComponent.bind({}); + +RawSource.parameters = { + docs: { + source: { + code: RawSourceCode, + language: 'tsx', + type: 'code', + }, + }, +}; diff --git a/code/addons/docs/template/stories/stories-mdx/raw-source.stories.mdx b/code/addons/docs/template/stories/stories-mdx/raw-source.stories.mdx new file mode 100644 index 000000000000..472febb7d053 --- /dev/null +++ b/code/addons/docs/template/stories/stories-mdx/raw-source.stories.mdx @@ -0,0 +1,9 @@ +import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs'; +import * as stories from './raw-source.non-stories'; +import { RawSource } from './RawSource'; + + + + + + \ No newline at end of file From eedfeedcd2a18a05efc9bdb56b33fb1fbf22d680 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Tue, 28 Nov 2023 15:28:00 +0100 Subject: [PATCH 3/4] fixes --- .../template/stories/stories-mdx/RawSource.jsx | 7 +++++++ .../stories/stories-mdx/raw-source.non-stories.js | 15 +++++++++++++++ .../stories/stories-mdx/raw-source.stories.mdx | 9 +++++++++ .../builder-webpack5/src/preview/loaders.ts | 1 + 4 files changed, 32 insertions(+) create mode 100644 code/addons/docs/template/stories/stories-mdx/RawSource.jsx create mode 100644 code/addons/docs/template/stories/stories-mdx/raw-source.non-stories.js create mode 100644 code/addons/docs/template/stories/stories-mdx/raw-source.stories.mdx diff --git a/code/addons/docs/template/stories/stories-mdx/RawSource.jsx b/code/addons/docs/template/stories/stories-mdx/RawSource.jsx new file mode 100644 index 000000000000..9bcc6c261cda --- /dev/null +++ b/code/addons/docs/template/stories/stories-mdx/RawSource.jsx @@ -0,0 +1,7 @@ +import React, { Fragment } from 'react'; + +export const MY_VALUE_I_WANT_TO_SHOW_IN_STORY = 'Hello World!'; + +export const RawSource = () => { + return {MY_VALUE_I_WANT_TO_SHOW_IN_STORY}; +}; \ No newline at end of file diff --git a/code/addons/docs/template/stories/stories-mdx/raw-source.non-stories.js b/code/addons/docs/template/stories/stories-mdx/raw-source.non-stories.js new file mode 100644 index 000000000000..358f4c64d7bd --- /dev/null +++ b/code/addons/docs/template/stories/stories-mdx/raw-source.non-stories.js @@ -0,0 +1,15 @@ +import { RawSource as RawSourceComponent } from './RawSource.jsx'; +// eslint-disable-next-line import/no-unresolved +import RawSourceCode from './RawSource.jsx?raw'; + +export const RawSource = RawSourceComponent.bind({}); + +RawSource.parameters = { + docs: { + source: { + code: RawSourceCode, + language: 'tsx', + type: 'code', + }, + }, +}; \ No newline at end of file diff --git a/code/addons/docs/template/stories/stories-mdx/raw-source.stories.mdx b/code/addons/docs/template/stories/stories-mdx/raw-source.stories.mdx new file mode 100644 index 000000000000..472febb7d053 --- /dev/null +++ b/code/addons/docs/template/stories/stories-mdx/raw-source.stories.mdx @@ -0,0 +1,9 @@ +import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs'; +import * as stories from './raw-source.non-stories'; +import { RawSource } from './RawSource'; + + + + + + \ No newline at end of file diff --git a/code/builders/builder-webpack5/src/preview/loaders.ts b/code/builders/builder-webpack5/src/preview/loaders.ts index 868d35ba394c..98e7dbd8efd9 100644 --- a/code/builders/builder-webpack5/src/preview/loaders.ts +++ b/code/builders/builder-webpack5/src/preview/loaders.ts @@ -20,6 +20,7 @@ export const createBabelLoader = async ( options: babelOptions, }, ], + resourceQuery: { not: [/raw/] }, include: [getProjectRoot()], exclude: [/node_modules/, ...excludes], }; From 0b644643e55a003a530898c46c961bba434ff322 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Tue, 28 Nov 2023 17:02:20 +0100 Subject: [PATCH 4/4] Revert "Docs: Raw support for `mjs`, `jsx`, and `tsx` files" --- .../template/stories/stories-mdx/RawSource.jsx | 7 ------- .../stories/stories-mdx/raw-source.non-stories.js | 15 --------------- .../stories/stories-mdx/raw-source.stories.mdx | 9 --------- .../builder-webpack5/src/preview/loaders.ts | 1 - 4 files changed, 32 deletions(-) delete mode 100644 code/addons/docs/template/stories/stories-mdx/RawSource.jsx delete mode 100644 code/addons/docs/template/stories/stories-mdx/raw-source.non-stories.js delete mode 100644 code/addons/docs/template/stories/stories-mdx/raw-source.stories.mdx diff --git a/code/addons/docs/template/stories/stories-mdx/RawSource.jsx b/code/addons/docs/template/stories/stories-mdx/RawSource.jsx deleted file mode 100644 index 9bcc6c261cda..000000000000 --- a/code/addons/docs/template/stories/stories-mdx/RawSource.jsx +++ /dev/null @@ -1,7 +0,0 @@ -import React, { Fragment } from 'react'; - -export const MY_VALUE_I_WANT_TO_SHOW_IN_STORY = 'Hello World!'; - -export const RawSource = () => { - return {MY_VALUE_I_WANT_TO_SHOW_IN_STORY}; -}; \ No newline at end of file diff --git a/code/addons/docs/template/stories/stories-mdx/raw-source.non-stories.js b/code/addons/docs/template/stories/stories-mdx/raw-source.non-stories.js deleted file mode 100644 index 358f4c64d7bd..000000000000 --- a/code/addons/docs/template/stories/stories-mdx/raw-source.non-stories.js +++ /dev/null @@ -1,15 +0,0 @@ -import { RawSource as RawSourceComponent } from './RawSource.jsx'; -// eslint-disable-next-line import/no-unresolved -import RawSourceCode from './RawSource.jsx?raw'; - -export const RawSource = RawSourceComponent.bind({}); - -RawSource.parameters = { - docs: { - source: { - code: RawSourceCode, - language: 'tsx', - type: 'code', - }, - }, -}; \ No newline at end of file diff --git a/code/addons/docs/template/stories/stories-mdx/raw-source.stories.mdx b/code/addons/docs/template/stories/stories-mdx/raw-source.stories.mdx deleted file mode 100644 index 472febb7d053..000000000000 --- a/code/addons/docs/template/stories/stories-mdx/raw-source.stories.mdx +++ /dev/null @@ -1,9 +0,0 @@ -import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs'; -import * as stories from './raw-source.non-stories'; -import { RawSource } from './RawSource'; - - - - - - \ No newline at end of file diff --git a/code/builders/builder-webpack5/src/preview/loaders.ts b/code/builders/builder-webpack5/src/preview/loaders.ts index 98e7dbd8efd9..868d35ba394c 100644 --- a/code/builders/builder-webpack5/src/preview/loaders.ts +++ b/code/builders/builder-webpack5/src/preview/loaders.ts @@ -20,7 +20,6 @@ export const createBabelLoader = async ( options: babelOptions, }, ], - resourceQuery: { not: [/raw/] }, include: [getProjectRoot()], exclude: [/node_modules/, ...excludes], };