Skip to content

Commit

Permalink
fix(docs): use require.resolve to ensure Yarn PnP compatibility
Browse files Browse the repository at this point in the history
Use `require.resolve` both for:
 - webpack loader
 - finding path, previously it was built assuming that `node_modules` directory exists which is false in Plug'n'PLay mode
  • Loading branch information
gaetanmaisse committed May 1, 2020
1 parent 4a5d710 commit d44ff25
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions addons/docs/src/frameworks/common/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function webpack(webpackConfig: any = {}, options: any = {}) {
include: new RegExp(`node_modules\\${path.sep}acorn-jsx`),
use: [
{
loader: 'babel-loader',
loader: require.resolve('babel-loader'),
options: {
presets: [[require.resolve('@babel/preset-env'), { modules: 'commonjs' }]],
},
Expand All @@ -77,11 +77,11 @@ export function webpack(webpackConfig: any = {}, options: any = {}) {
test: /\.(stories|story).mdx$/,
use: [
{
loader: 'babel-loader',
loader: require.resolve('babel-loader'),
options: createBabelOptions(babelOptions, configureJSX),
},
{
loader: '@mdx-js/loader',
loader: require.resolve('@mdx-js/loader'),
options: {
compilers: [createCompiler(options)],
...mdxLoaderOptions,
Expand All @@ -94,11 +94,11 @@ export function webpack(webpackConfig: any = {}, options: any = {}) {
exclude: /\.(stories|story).mdx$/,
use: [
{
loader: 'babel-loader',
loader: require.resolve('babel-loader'),
options: createBabelOptions(babelOptions, configureJSX),
},
{
loader: '@mdx-js/loader',
loader: require.resolve('@mdx-js/loader'),
options: mdxLoaderOptions,
},
],
Expand All @@ -112,7 +112,7 @@ export function webpack(webpackConfig: any = {}, options: any = {}) {
result.plugins.push(
new DllReferencePlugin({
context,
manifest: path.join(coreDirName, 'dll', 'storybook_docs-manifest.json'),
manifest: require.resolve('@storybook/core/dll/storybook_docs-manifest.json'),
})
);
}
Expand Down

0 comments on commit d44ff25

Please sign in to comment.