@storybook/addon-docs 6.5.0-alpha.41 → 6.5.0-alpha.44

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.
@@ -49,7 +49,7 @@ var _remarkSlug = _interopRequireDefault(require("remark-slug"));
49
49
 
50
50
  var _remarkExternalLinks = _interopRequireDefault(require("remark-external-links"));
51
51
 
52
- var _mdx = require("@storybook/csf-tools/mdx");
52
+ var _global = _interopRequireDefault(require("global"));
53
53
 
54
54
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
55
55
 
@@ -69,6 +69,11 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
69
69
 
70
70
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
71
71
 
72
+ var _console = console,
73
+ log = _console.log; // for frameworks that are not working with react, we need to configure
74
+ // the jsx to transpile mdx, for now there will be a flag for that
75
+ // for more complex solutions we can find alone that we need to add '@babel/plugin-transform-react-jsx'
76
+
72
77
  function createBabelOptions(_ref) {
73
78
  var babelOptions = _ref.babelOptions,
74
79
  mdxBabelOptions = _ref.mdxBabelOptions,
@@ -94,6 +99,8 @@ function webpack() {
94
99
 
95
100
  function _webpack() {
96
101
  _webpack = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
102
+ var _global$FEATURES, _global$FEATURES2;
103
+
97
104
  var webpackConfig,
98
105
  options,
99
106
  _yield$options$preset,
@@ -112,6 +119,8 @@ function _webpack() {
112
119
  _options$transcludeMa,
113
120
  transcludeMarkdown,
114
121
  mdxLoaderOptions,
122
+ mdxVersion,
123
+ mdxLoader,
115
124
  sourceLoader,
116
125
  rules,
117
126
  result,
@@ -132,7 +141,7 @@ function _webpack() {
132
141
  builder = _yield$options$preset2 === void 0 ? 'webpack4' : _yield$options$preset2;
133
142
  builderName = typeof builder === 'string' ? builder : builder.name;
134
143
  resolvedBabelLoader = require.resolve('babel-loader', {
135
- paths: builderName.match(/(webpack4|webpack5)/) ? [require.resolve("@storybook/builder-".concat(builder))] : [builderName]
144
+ paths: builderName.match(/^webpack(4|5)$/) ? [require.resolve("@storybook/builder-".concat(builderName))] : [builderName]
136
145
  });
137
146
  _webpackConfig$module = webpackConfig.module, module = _webpackConfig$module === void 0 ? {} : _webpackConfig$module; // it will reuse babel options that are already in use in storybook
138
147
  // also, these babel options are chained with other presets.
@@ -141,8 +150,12 @@ function _webpack() {
141
150
  injectStoryParameters: true
142
151
  } : _options$sourceLoader, _options$transcludeMa = options.transcludeMarkdown, transcludeMarkdown = _options$transcludeMa === void 0 ? false : _options$transcludeMa;
143
152
  mdxLoaderOptions = {
153
+ skipCsf: true,
144
154
  remarkPlugins: [_remarkSlug.default, _remarkExternalLinks.default]
145
- }; // set `sourceLoaderOptions` to `null` to disable for manual configuration
155
+ };
156
+ mdxVersion = (_global$FEATURES = _global.default.FEATURES) !== null && _global$FEATURES !== void 0 && _global$FEATURES.previewMdx2 ? 'MDX2' : 'MDX1';
157
+ log("Addon-docs: using ".concat(mdxVersion));
158
+ mdxLoader = (_global$FEATURES2 = _global.default.FEATURES) !== null && _global$FEATURES2 !== void 0 && _global$FEATURES2.previewMdx2 ? require.resolve('@storybook/mdx2-csf/loader') : require.resolve('@storybook/mdx1-csf/loader'); // set `sourceLoaderOptions` to `null` to disable for manual configuration
146
159
 
147
160
  sourceLoader = sourceLoaderOptions ? [{
148
161
  test: /\.(stories|story)\.[tj]sx?$/,
@@ -169,7 +182,7 @@ function _webpack() {
169
182
  configureJSX: configureJSX
170
183
  })
171
184
  }, {
172
- loader: require.resolve('@mdx-js/loader'),
185
+ loader: mdxLoader,
173
186
  options: mdxLoaderOptions
174
187
  }]
175
188
  }]);
@@ -198,10 +211,7 @@ function _webpack() {
198
211
  configureJSX: configureJSX
199
212
  })
200
213
  }, {
201
- loader: require.resolve('@mdx-js/loader'),
202
- options: Object.assign({
203
- compilers: [(0, _mdx.createCompiler)(options)]
204
- }, mdxLoaderOptions)
214
+ loader: mdxLoader
205
215
  }]
206
216
  }, {
207
217
  test: /\.mdx$/,
@@ -214,7 +224,7 @@ function _webpack() {
214
224
  configureJSX: configureJSX
215
225
  })
216
226
  }, {
217
- loader: require.resolve('@mdx-js/loader'),
227
+ loader: mdxLoader,
218
228
  options: mdxLoaderOptions
219
229
  }]
220
230
  }], sourceLoader)
@@ -222,7 +232,7 @@ function _webpack() {
222
232
  });
223
233
  return _context.abrupt("return", result);
224
234
 
225
- case 17:
235
+ case 20:
226
236
  case "end":
227
237
  return _context.stop();
228
238
  }
@@ -37,9 +37,12 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
37
37
 
38
38
  import path from 'path';
39
39
  import remarkSlug from 'remark-slug';
40
- import remarkExternalLinks from 'remark-external-links'; // @ts-ignore
41
-
42
- import { createCompiler } from '@storybook/csf-tools/mdx';
40
+ import remarkExternalLinks from 'remark-external-links';
41
+ import global from 'global';
42
+ var _console = console,
43
+ log = _console.log; // for frameworks that are not working with react, we need to configure
44
+ // the jsx to transpile mdx, for now there will be a flag for that
45
+ // for more complex solutions we can find alone that we need to add '@babel/plugin-transform-react-jsx'
43
46
 
44
47
  function createBabelOptions(_ref) {
45
48
  var babelOptions = _ref.babelOptions,
@@ -66,6 +69,8 @@ export function webpack() {
66
69
 
67
70
  function _webpack() {
68
71
  _webpack = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
72
+ var _global$FEATURES, _global$FEATURES2;
73
+
69
74
  var webpackConfig,
70
75
  options,
71
76
  _yield$options$preset,
@@ -84,6 +89,8 @@ function _webpack() {
84
89
  _options$transcludeMa,
85
90
  transcludeMarkdown,
86
91
  mdxLoaderOptions,
92
+ mdxVersion,
93
+ mdxLoader,
87
94
  sourceLoader,
88
95
  rules,
89
96
  result,
@@ -104,7 +111,7 @@ function _webpack() {
104
111
  builder = _yield$options$preset2 === void 0 ? 'webpack4' : _yield$options$preset2;
105
112
  builderName = typeof builder === 'string' ? builder : builder.name;
106
113
  resolvedBabelLoader = require.resolve('babel-loader', {
107
- paths: builderName.match(/(webpack4|webpack5)/) ? [require.resolve("@storybook/builder-".concat(builder))] : [builderName]
114
+ paths: builderName.match(/^webpack(4|5)$/) ? [require.resolve("@storybook/builder-".concat(builderName))] : [builderName]
108
115
  });
109
116
  _webpackConfig$module = webpackConfig.module, module = _webpackConfig$module === void 0 ? {} : _webpackConfig$module; // it will reuse babel options that are already in use in storybook
110
117
  // also, these babel options are chained with other presets.
@@ -113,8 +120,12 @@ function _webpack() {
113
120
  injectStoryParameters: true
114
121
  } : _options$sourceLoader, _options$transcludeMa = options.transcludeMarkdown, transcludeMarkdown = _options$transcludeMa === void 0 ? false : _options$transcludeMa;
115
122
  mdxLoaderOptions = {
123
+ skipCsf: true,
116
124
  remarkPlugins: [remarkSlug, remarkExternalLinks]
117
- }; // set `sourceLoaderOptions` to `null` to disable for manual configuration
125
+ };
126
+ mdxVersion = (_global$FEATURES = global.FEATURES) !== null && _global$FEATURES !== void 0 && _global$FEATURES.previewMdx2 ? 'MDX2' : 'MDX1';
127
+ log("Addon-docs: using ".concat(mdxVersion));
128
+ mdxLoader = (_global$FEATURES2 = global.FEATURES) !== null && _global$FEATURES2 !== void 0 && _global$FEATURES2.previewMdx2 ? require.resolve('@storybook/mdx2-csf/loader') : require.resolve('@storybook/mdx1-csf/loader'); // set `sourceLoaderOptions` to `null` to disable for manual configuration
118
129
 
119
130
  sourceLoader = sourceLoaderOptions ? [{
120
131
  test: /\.(stories|story)\.[tj]sx?$/,
@@ -141,7 +152,7 @@ function _webpack() {
141
152
  configureJSX: configureJSX
142
153
  })
143
154
  }, {
144
- loader: require.resolve('@mdx-js/loader'),
155
+ loader: mdxLoader,
145
156
  options: mdxLoaderOptions
146
157
  }]
147
158
  }]);
@@ -170,10 +181,7 @@ function _webpack() {
170
181
  configureJSX: configureJSX
171
182
  })
172
183
  }, {
173
- loader: require.resolve('@mdx-js/loader'),
174
- options: Object.assign({
175
- compilers: [createCompiler(options)]
176
- }, mdxLoaderOptions)
184
+ loader: mdxLoader
177
185
  }]
178
186
  }, {
179
187
  test: /\.mdx$/,
@@ -186,7 +194,7 @@ function _webpack() {
186
194
  configureJSX: configureJSX
187
195
  })
188
196
  }, {
189
- loader: require.resolve('@mdx-js/loader'),
197
+ loader: mdxLoader,
190
198
  options: mdxLoaderOptions
191
199
  }]
192
200
  }], sourceLoader)
@@ -194,7 +202,7 @@ function _webpack() {
194
202
  });
195
203
  return _context.abrupt("return", result);
196
204
 
197
- case 17:
205
+ case 20:
198
206
  case "end":
199
207
  return _context.stop();
200
208
  }
@@ -1,8 +1,12 @@
1
1
  import path from 'path';
2
2
  import remarkSlug from 'remark-slug';
3
- import remarkExternalLinks from 'remark-external-links'; // @ts-ignore
4
-
5
- import { createCompiler } from '@storybook/csf-tools/mdx';
3
+ import remarkExternalLinks from 'remark-external-links';
4
+ import global from 'global';
5
+ const {
6
+ log
7
+ } = console; // for frameworks that are not working with react, we need to configure
8
+ // the jsx to transpile mdx, for now there will be a flag for that
9
+ // for more complex solutions we can find alone that we need to add '@babel/plugin-transform-react-jsx'
6
10
 
7
11
  function createBabelOptions({
8
12
  babelOptions,
@@ -25,13 +29,15 @@ function createBabelOptions({
25
29
  }
26
30
 
27
31
  export async function webpack(webpackConfig = {}, options) {
32
+ var _global$FEATURES, _global$FEATURES2;
33
+
28
34
  const {
29
35
  builder = 'webpack4'
30
36
  } = await options.presets.apply('core', {});
31
37
  const builderName = typeof builder === 'string' ? builder : builder.name;
32
38
 
33
39
  const resolvedBabelLoader = require.resolve('babel-loader', {
34
- paths: builderName.match(/(webpack4|webpack5)/) ? [require.resolve(`@storybook/builder-${builder}`)] : [builderName]
40
+ paths: builderName.match(/^webpack(4|5)$/) ? [require.resolve(`@storybook/builder-${builderName}`)] : [builderName]
35
41
  });
36
42
 
37
43
  const {
@@ -49,8 +55,12 @@ export async function webpack(webpackConfig = {}, options) {
49
55
  transcludeMarkdown = false
50
56
  } = options;
51
57
  const mdxLoaderOptions = {
58
+ skipCsf: true,
52
59
  remarkPlugins: [remarkSlug, remarkExternalLinks]
53
- }; // set `sourceLoaderOptions` to `null` to disable for manual configuration
60
+ };
61
+ const mdxVersion = (_global$FEATURES = global.FEATURES) !== null && _global$FEATURES !== void 0 && _global$FEATURES.previewMdx2 ? 'MDX2' : 'MDX1';
62
+ log(`Addon-docs: using ${mdxVersion}`);
63
+ const mdxLoader = (_global$FEATURES2 = global.FEATURES) !== null && _global$FEATURES2 !== void 0 && _global$FEATURES2.previewMdx2 ? require.resolve('@storybook/mdx2-csf/loader') : require.resolve('@storybook/mdx1-csf/loader'); // set `sourceLoaderOptions` to `null` to disable for manual configuration
54
64
 
55
65
  const sourceLoader = sourceLoaderOptions ? [{
56
66
  test: /\.(stories|story)\.[tj]sx?$/,
@@ -77,7 +87,7 @@ export async function webpack(webpackConfig = {}, options) {
77
87
  configureJSX
78
88
  })
79
89
  }, {
80
- loader: require.resolve('@mdx-js/loader'),
90
+ loader: mdxLoader,
81
91
  options: mdxLoaderOptions
82
92
  }]
83
93
  }];
@@ -106,10 +116,7 @@ export async function webpack(webpackConfig = {}, options) {
106
116
  configureJSX
107
117
  })
108
118
  }, {
109
- loader: require.resolve('@mdx-js/loader'),
110
- options: Object.assign({
111
- compilers: [createCompiler(options)]
112
- }, mdxLoaderOptions)
119
+ loader: mdxLoader
113
120
  }]
114
121
  }, {
115
122
  test: /\.mdx$/,
@@ -122,7 +129,7 @@ export async function webpack(webpackConfig = {}, options) {
122
129
  configureJSX
123
130
  })
124
131
  }, {
125
- loader: require.resolve('@mdx-js/loader'),
132
+ loader: mdxLoader,
126
133
  options: mdxLoaderOptions
127
134
  }]
128
135
  }, ...sourceLoader]
@@ -1,4 +1,3 @@
1
- import { createCompiler } from '@storybook/csf-tools/mdx';
2
1
  import { Options } from '@storybook/core-common';
3
2
  declare type BabelParams = {
4
3
  babelOptions?: any;
@@ -8,5 +7,5 @@ declare type BabelParams = {
8
7
  export declare function webpack(webpackConfig: any, options: Options & BabelParams & {
9
8
  sourceLoaderOptions: any;
10
9
  transcludeMarkdown: boolean;
11
- } & Parameters<typeof createCompiler>[0]): Promise<any>;
10
+ }): Promise<any>;
12
11
  export {};
@@ -1,4 +1,3 @@
1
- import { createCompiler } from '@storybook/csf-tools/mdx';
2
1
  import type { Options } from '@storybook/core-common';
3
2
  declare type BabelParams = {
4
3
  babelOptions?: any;
@@ -8,5 +7,5 @@ declare type BabelParams = {
8
7
  export declare function webpack(webpackConfig: any, options: Options & BabelParams & {
9
8
  sourceLoaderOptions: any;
10
9
  transcludeMarkdown: boolean;
11
- } & Parameters<typeof createCompiler>[0]): Promise<any>;
10
+ }): Promise<any>;
12
11
  export {};
@@ -1,11 +1,8 @@
1
1
  const path = require('path');
2
- const mdx = require('@mdx-js/mdx');
3
2
  const { ScriptTransformer } = require('@jest/transform');
4
3
  const { dedent } = require('ts-dedent');
5
4
 
6
- const { createCompiler } = require('@storybook/csf-tools/mdx');
7
-
8
- const compilers = [createCompiler({})];
5
+ const { compileSync } = require('@storybook/mdx1-csf');
9
6
 
10
7
  module.exports = {
11
8
  process(src, filename, config, { instrument }) {
@@ -13,7 +10,7 @@ module.exports = {
13
10
  /* @jsx mdx */
14
11
  import React from 'react'
15
12
  import { mdx } from '@mdx-js/react'
16
- ${mdx.sync(src, { compilers, filepath: filename })}
13
+ ${compileSync(src, { filepath: filename })}
17
14
  `;
18
15
 
19
16
  const extension = path.extname(filename);
@@ -1 +1 @@
1
- module.exports = require('@storybook/csf-tools/mdx').createCompiler;
1
+ module.exports = require('@storybook/mdx1-csf').createCompiler;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/addon-docs",
3
- "version": "6.5.0-alpha.41",
3
+ "version": "6.5.0-alpha.44",
4
4
  "description": "Document component usage and properties in Markdown",
5
5
  "keywords": [
6
6
  "addon",
@@ -61,24 +61,23 @@
61
61
  "@babel/plugin-transform-react-jsx": "^7.12.12",
62
62
  "@babel/preset-env": "^7.12.11",
63
63
  "@jest/transform": "^26.6.2",
64
- "@mdx-js/loader": "^1.6.22",
65
- "@mdx-js/mdx": "^1.6.22",
66
64
  "@mdx-js/react": "^1.6.22",
67
- "@storybook/addons": "6.5.0-alpha.41",
68
- "@storybook/api": "6.5.0-alpha.41",
69
- "@storybook/builder-webpack4": "6.5.0-alpha.41",
70
- "@storybook/client-logger": "6.5.0-alpha.41",
71
- "@storybook/components": "6.5.0-alpha.41",
72
- "@storybook/core": "6.5.0-alpha.41",
73
- "@storybook/core-events": "6.5.0-alpha.41",
65
+ "@storybook/addons": "6.5.0-alpha.44",
66
+ "@storybook/api": "6.5.0-alpha.44",
67
+ "@storybook/builder-webpack4": "6.5.0-alpha.44",
68
+ "@storybook/client-logger": "6.5.0-alpha.44",
69
+ "@storybook/components": "6.5.0-alpha.44",
70
+ "@storybook/core": "6.5.0-alpha.44",
71
+ "@storybook/core-events": "6.5.0-alpha.44",
74
72
  "@storybook/csf": "0.0.2--canary.87bc651.0",
75
- "@storybook/csf-tools": "6.5.0-alpha.41",
76
- "@storybook/node-logger": "6.5.0-alpha.41",
77
- "@storybook/postinstall": "6.5.0-alpha.41",
78
- "@storybook/preview-web": "6.5.0-alpha.41",
79
- "@storybook/source-loader": "6.5.0-alpha.41",
80
- "@storybook/store": "6.5.0-alpha.41",
81
- "@storybook/theming": "6.5.0-alpha.41",
73
+ "@storybook/csf-tools": "6.5.0-alpha.44",
74
+ "@storybook/mdx1-csf": "canary",
75
+ "@storybook/node-logger": "6.5.0-alpha.44",
76
+ "@storybook/postinstall": "6.5.0-alpha.44",
77
+ "@storybook/preview-web": "6.5.0-alpha.44",
78
+ "@storybook/source-loader": "6.5.0-alpha.44",
79
+ "@storybook/store": "6.5.0-alpha.44",
80
+ "@storybook/theming": "6.5.0-alpha.44",
82
81
  "acorn": "^7.4.1",
83
82
  "acorn-jsx": "^5.3.1",
84
83
  "acorn-walk": "^7.2.0",
@@ -88,7 +87,6 @@
88
87
  "fast-deep-equal": "^3.1.3",
89
88
  "global": "^4.4.0",
90
89
  "html-tags": "^3.1.0",
91
- "js-string-escape": "^1.0.1",
92
90
  "loader-utils": "^2.0.0",
93
91
  "lodash": "^4.17.21",
94
92
  "nanoid": "^3.1.23",
@@ -107,16 +105,15 @@
107
105
  "@babel/core": "^7.12.10",
108
106
  "@emotion/core": "^10.3.1",
109
107
  "@emotion/styled": "^10.0.27",
110
- "@storybook/angular": "6.5.0-alpha.41",
111
- "@storybook/html": "6.5.0-alpha.41",
112
- "@storybook/react": "6.5.0-alpha.41",
113
- "@storybook/vue": "6.5.0-alpha.41",
114
- "@storybook/web-components": "6.5.0-alpha.41",
108
+ "@storybook/angular": "6.5.0-alpha.44",
109
+ "@storybook/html": "6.5.0-alpha.44",
110
+ "@storybook/mdx2-csf": "canary",
111
+ "@storybook/react": "6.5.0-alpha.44",
112
+ "@storybook/vue": "6.5.0-alpha.44",
113
+ "@storybook/web-components": "6.5.0-alpha.44",
115
114
  "@types/cross-spawn": "^6.0.2",
116
115
  "@types/doctrine": "^0.0.3",
117
- "@types/enzyme": "^3.10.8",
118
116
  "@types/estree": "^0.0.44",
119
- "@types/jest": "^26.0.16",
120
117
  "@types/loader-utils": "^2.0.0",
121
118
  "@types/prop-types": "^15.7.3",
122
119
  "@types/tmp": "^0.2.0",
@@ -124,7 +121,6 @@
124
121
  "babel-loader": "^8.0.0",
125
122
  "babel-plugin-react-docgen": "^4.2.1",
126
123
  "cross-spawn": "^7.0.3",
127
- "fs-extra": "^9.0.1",
128
124
  "jest": "^26.6.3",
129
125
  "jest-specific-snapshot": "^4.0.0",
130
126
  "lit-element": "^3.0.2",
@@ -134,12 +130,27 @@
134
130
  "styled-components": "^5.2.1",
135
131
  "sveltedoc-parser": "4.1.0",
136
132
  "tmp": "^0.2.1",
137
- "tslib": "^2.1.0",
138
133
  "vue": "^2.6.10",
139
- "web-component-analyzer": "^1.1.6",
140
134
  "webpack": "4",
141
135
  "zone.js": "^0.11.3"
142
136
  },
137
+ "peerDependencies": {
138
+ "@storybook/angular": "6.5.0-alpha.44",
139
+ "@storybook/html": "6.5.0-alpha.44",
140
+ "@storybook/mdx2-csf": "*",
141
+ "@storybook/react": "6.5.0-alpha.44",
142
+ "@storybook/vue": "6.5.0-alpha.44",
143
+ "@storybook/vue3": "6.5.0-alpha.44",
144
+ "@storybook/web-components": "6.5.0-alpha.44",
145
+ "lit": "^2.0.0",
146
+ "lit-html": "^1.4.1 || ^2.0.0",
147
+ "react": "^16.8.0 || ^17.0.0",
148
+ "react-dom": "^16.8.0 || ^17.0.0",
149
+ "svelte": "^3.31.2",
150
+ "sveltedoc-parser": "^4.1.0",
151
+ "vue": "^2.6.10 || ^3.0.0",
152
+ "webpack": "*"
153
+ },
143
154
  "peerDependenciesMeta": {
144
155
  "@storybook/angular": {
145
156
  "optional": true
@@ -159,6 +170,9 @@
159
170
  "@storybook/manager-webpack5": {
160
171
  "optional": true
161
172
  },
173
+ "@storybook/mdx2-csf": {
174
+ "optional": true
175
+ },
162
176
  "@storybook/react": {
163
177
  "optional": true
164
178
  },
@@ -199,7 +213,7 @@
199
213
  "publishConfig": {
200
214
  "access": "public"
201
215
  },
202
- "gitHead": "10663a4c9ea6c04a04047b5bb22254d6b64201c2",
216
+ "gitHead": "0125cb2b688dc1acca71a7fbf2795466fd55c0e3",
203
217
  "sbmodern": "dist/modern/index.js",
204
218
  "storybook": {
205
219
  "displayName": "Docs",