@teambit/preview 1.0.884 → 1.0.886

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.
@@ -0,0 +1,268 @@
1
+ import { rspack, type Configuration } from '@rspack/core';
2
+ import { fallbacksProvidePluginConfig, fallbacks } from '@teambit/webpack';
3
+ import { mdxOptions } from '@teambit/mdx.modules.mdx-v3-options';
4
+ import { RspackManifestPlugin } from 'rspack-manifest-plugin';
5
+ import { generateAssetManifest } from '@teambit/rspack.modules.generate-asset-manifest';
6
+
7
+ const moduleFileExtensions = [
8
+ 'web.mjs',
9
+ 'mjs',
10
+ 'web.js',
11
+ 'js',
12
+ 'web.ts',
13
+ 'ts',
14
+ 'web.tsx',
15
+ 'tsx',
16
+ 'json',
17
+ 'web.jsx',
18
+ 'jsx',
19
+ 'mdx',
20
+ 'md',
21
+ ];
22
+
23
+ const imageInlineSizeLimit = parseInt(process.env.IMAGE_INLINE_SIZE_LIMIT || '10000');
24
+ const cssModuleGenerator = { localIdentName: '[name]__[local]--[hash:base64:5]', esModule: false };
25
+ const cssParser = {
26
+ css: { namedExports: false },
27
+ 'css/auto': { namedExports: false },
28
+ 'css/module': { namedExports: false },
29
+ } as const;
30
+
31
+ export function createRspackConfig(outputDir: string, entryFile: string): Configuration {
32
+ const mode = process.env.BIT_DEBUG_PREVIEW_BUNDLE ? 'development' : 'production';
33
+ const shouldUseSourceMap = mode === 'development' || process.env.GENERATE_SOURCEMAP === 'true';
34
+
35
+ return {
36
+ stats: {
37
+ children: true,
38
+ errorDetails: true,
39
+ },
40
+ mode,
41
+
42
+ devtool: shouldUseSourceMap ? 'source-map' : false,
43
+ experiments: {
44
+ css: true,
45
+ },
46
+
47
+ entry: {
48
+ main: entryFile,
49
+ },
50
+
51
+ output: {
52
+ path: outputDir,
53
+ publicPath: '/',
54
+ chunkFilename: 'static/js/[name].[contenthash:8].chunk.cjs',
55
+ filename: 'static/js/[name].[contenthash:8].cjs',
56
+ cssFilename: 'static/css/[name].[contenthash:8].css',
57
+ cssChunkFilename: 'static/css/[name].[contenthash:8].chunk.css',
58
+ library: {
59
+ type: 'commonjs-static',
60
+ },
61
+ },
62
+
63
+ externalsType: 'commonjs',
64
+ externals: ['react', 'react-dom', '@mdx-js/react', '@teambit/mdx.ui.mdx-scope-context'],
65
+
66
+ resolve: {
67
+ extensions: moduleFileExtensions.map((ext) => `.${ext}`),
68
+ alias: {
69
+ 'react/jsx-runtime': require.resolve('react/jsx-runtime'),
70
+ react: require.resolve('react'),
71
+ 'react-dom': require.resolve('react-dom'),
72
+ },
73
+ fallback: {
74
+ module: false,
75
+ path: fallbacks.path,
76
+ dgram: false,
77
+ dns: false,
78
+ fs: false,
79
+ stream: false,
80
+ http2: false,
81
+ net: false,
82
+ tls: false,
83
+ child_process: false,
84
+ process: fallbacks.process,
85
+ },
86
+ },
87
+
88
+ optimization: {
89
+ minimize: mode === 'production',
90
+ minimizer: [
91
+ new rspack.SwcJsMinimizerRspackPlugin({
92
+ minimizerOptions: {
93
+ compress: {
94
+ ecma: 5,
95
+ comparisons: false,
96
+ inline: 2,
97
+ },
98
+ // We need to keep class names and disable mangling to prevent issues with consuming the rspack bundle in
99
+ // other bundlers (e.g. webpack) that rely on class names for tree shaking and other optimizations.
100
+ mangle: false,
101
+ format: {
102
+ ecma: 5,
103
+ comments: false,
104
+ ascii_only: true,
105
+ },
106
+ },
107
+ }),
108
+ new rspack.LightningCssMinimizerRspackPlugin({}),
109
+ ],
110
+ },
111
+
112
+ module: {
113
+ parser: cssParser,
114
+ rules: [
115
+ {
116
+ test: /\.m?js/,
117
+ resolve: {
118
+ fullySpecified: false,
119
+ },
120
+ },
121
+ {
122
+ test: /\.(js|mjs|jsx|ts|tsx)$/,
123
+ exclude: /node_modules/,
124
+ use: {
125
+ loader: 'builtin:swc-loader',
126
+ options: {
127
+ jsc: {
128
+ parser: {
129
+ syntax: 'typescript',
130
+ tsx: true,
131
+ },
132
+ transform: {
133
+ react: {
134
+ runtime: 'automatic',
135
+ },
136
+ },
137
+ target: 'es2015',
138
+ },
139
+ },
140
+ },
141
+ type: 'javascript/auto',
142
+ },
143
+ {
144
+ test: /\.js$/,
145
+ enforce: 'pre' as const,
146
+ include: /node_modules/,
147
+ descriptionData: { componentId: (value: any) => !!value },
148
+ extractSourceMap: shouldUseSourceMap,
149
+ },
150
+ {
151
+ test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
152
+ type: 'asset',
153
+ parser: {
154
+ dataUrlCondition: {
155
+ maxSize: imageInlineSizeLimit,
156
+ },
157
+ },
158
+ },
159
+ {
160
+ test: /\.svg$/,
161
+ type: 'asset',
162
+ parser: {
163
+ dataUrlCondition: {
164
+ maxSize: imageInlineSizeLimit,
165
+ },
166
+ },
167
+ },
168
+ {
169
+ test: /\.css$/,
170
+ exclude: /\.module\.css$/,
171
+ type: 'css',
172
+ sideEffects: true,
173
+ },
174
+ {
175
+ test: /\.module\.css$/,
176
+ type: 'css/module',
177
+ generator: cssModuleGenerator,
178
+ },
179
+ {
180
+ test: /\.(scss|sass)$/,
181
+ exclude: /\.module\.(scss|sass)$/,
182
+ use: [
183
+ {
184
+ loader: require.resolve('resolve-url-loader'),
185
+ options: { sourceMap: shouldUseSourceMap },
186
+ },
187
+ {
188
+ loader: require.resolve('sass-loader'),
189
+ options: { sourceMap: shouldUseSourceMap },
190
+ },
191
+ ],
192
+ type: 'css',
193
+ sideEffects: true,
194
+ },
195
+ {
196
+ test: /\.module\.(scss|sass)$/,
197
+ use: [
198
+ {
199
+ loader: require.resolve('resolve-url-loader'),
200
+ options: { sourceMap: shouldUseSourceMap },
201
+ },
202
+ {
203
+ loader: require.resolve('sass-loader'),
204
+ options: { sourceMap: shouldUseSourceMap },
205
+ },
206
+ ],
207
+ type: 'css/module',
208
+ generator: cssModuleGenerator,
209
+ },
210
+ {
211
+ test: /\.(woff(2)?|ttf|eot)(\?v=\d+\.\d+\.\d+)?$/,
212
+ type: 'asset',
213
+ generator: {
214
+ filename: 'static/fonts/[hash][ext][query]',
215
+ },
216
+ },
217
+ {
218
+ test: /\.mdx?$/,
219
+ use: [
220
+ {
221
+ loader: 'builtin:swc-loader',
222
+ options: {
223
+ jsc: {
224
+ parser: {
225
+ syntax: 'typescript',
226
+ tsx: true,
227
+ },
228
+ transform: {
229
+ react: {
230
+ runtime: 'automatic',
231
+ },
232
+ },
233
+ target: 'es2015',
234
+ },
235
+ },
236
+ },
237
+ {
238
+ loader: require.resolve('@mdx-js/loader'),
239
+ options: mdxOptions,
240
+ },
241
+ {
242
+ // transforms admonition syntax (:::type content → :::type[content]) for mdx v3
243
+ loader: require.resolve('@teambit/react/dist/webpack/mdx-pre-loader.cjs'),
244
+ },
245
+ ],
246
+ type: 'javascript/auto',
247
+ },
248
+ {
249
+ exclude: [/\.(cjs|js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/, /\.css$/, /\.s[ac]ss$/, /\.less$/, /\.mdx?$/],
250
+ type: 'asset/resource',
251
+ },
252
+ ],
253
+ },
254
+
255
+ plugins: [
256
+ new RspackManifestPlugin({ fileName: 'asset-manifest.json', generate: generateAssetManifest }),
257
+
258
+ new rspack.ProvidePlugin({ process: fallbacksProvidePluginConfig.process }),
259
+
260
+ new rspack.IgnorePlugin({
261
+ resourceRegExp: /^\.\/locale$/,
262
+ contextRegExp: /moment$/,
263
+ }),
264
+ ],
265
+
266
+ performance: false,
267
+ };
268
+ }
@@ -1,5 +0,0 @@
1
- .frame_overlayBorder__4pB4S{box-sizing:border-box;border:2px solid #eebcc9;border:2px solid var(--bit-highlighter-color, #eebcc9);border-radius:11px;padding:4px;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.frame_hidden__F0shs{display:none}
2
- .label_othersContainer__\+rhM5>*{margin-bottom:8px}.label_othersContainer__\+rhM5>*:last-child{margin-bottom:0;margin-bottom:initial}.label_othersTooltip__FsGq5{-webkit-user-select:none;-moz-user-select:none;user-select:none;cursor:pointer}.label_othersTooltip__FsGq5::before{display:inline-block;transition:transform 300ms;content:"▾"}.label_othersTooltip__FsGq5.label_active__E6KIP::before{transform:rotate(-180deg)}.label_hidden__ZtHoV{visibility:hidden;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}
3
- .component-strip_componentStrip__eCupE{display:flex;width:-moz-fit-content;width:fit-content;border-radius:.5em;box-shadow:var(--bit-highlighter-shadow);white-space:nowrap}.component-strip_componentStrip__eCupE>*{padding:0 .5em;line-height:1.5;transition:filter 300ms,background-color 300ms;transform:translateZ(0);background:#eebcc9;background:var(--bit-highlighter-color, #eebcc9);margin-right:.125em}.component-strip_componentStrip__eCupE>*:link,.component-strip_componentStrip__eCupE>*:visited{text-decoration:inherit;color:inherit}.component-strip_componentStrip__eCupE>*:link:hover,.component-strip_componentStrip__eCupE>*:visited:hover{background:#f6dae2;background:var(--bit-highlighter-color-hover, #f6dae2)}.component-strip_componentStrip__eCupE>*:link:active,.component-strip_componentStrip__eCupE>*:visited:active{background:#e79db1;background:var(--bit-highlighter-color-active, #e79db1);color:inherit}.component-strip_componentStrip__eCupE>*:first-child{border-top-left-radius:.5em;border-bottom-left-radius:.5em}.component-strip_componentStrip__eCupE>*:last-child{border-top-right-radius:.5em;border-bottom-right-radius:.5em;margin-right:0;margin-right:initial}.component-strip_nameBlock__URo7m{display:flex}.component-strip_nameBlock__URo7m .component-strip_version__KGQOB{max-width:13ch;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;transition:max-width 480ms}.component-strip_nameBlock__URo7m .component-strip_version__KGQOB:hover{max-width:61ch}
4
- .element-highlighter_label__UFbc1{padding:8px}.element-highlighter_frame__0eJ5V,.element-highlighter_label__UFbc1{z-index:15500}
5
- .highlighter-provider_highlighter__vY8on{border:solid #ededed;border:solid var(--bit-border-color-lightest, #ededed);border-width:0px;box-sizing:border-box;height:100%;transition:border 300ms}.highlighter-provider_highlighter__vY8on.highlighter-provider_active__xgxqx{border-width:8px;overflow:auto}.highlighter-provider_label__iLN6B{font-family:sans-serif;font-size:12px}