@tarojs/plugin-framework-react 4.0.0-canary.1 → 4.0.0-canary.10
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.
- package/LICENSE +14 -0
- package/dist/api-loader.js.map +1 -1
- package/dist/index.js +164 -32
- package/dist/index.js.map +1 -1
- package/dist/reconciler.js +347 -0
- package/dist/reconciler.js.map +1 -0
- package/dist/runtime.js +291 -61
- package/dist/runtime.js.map +1 -1
- package/package.json +19 -10
package/LICENSE
CHANGED
|
@@ -158,3 +158,17 @@ MIT (stencil-vue2-output-target):
|
|
|
158
158
|
The following files embed [stencil-vue2-output-target](https://github.com/diondree/stencil-vue2-output-target) MIT:
|
|
159
159
|
`/packages/taro-components-library-vue2/src/vue-component-lib/utils.ts`
|
|
160
160
|
See `/LICENSE` for details of the license.
|
|
161
|
+
|
|
162
|
+
==================
|
|
163
|
+
|
|
164
|
+
MIT (weui):
|
|
165
|
+
The following files embed [stencil-vue2-output-target](https://github.com/Tencent/weui) MIT:
|
|
166
|
+
`/packages/taro-components/src/components/*.scss`
|
|
167
|
+
See `/LICENSE.txt` for details of the license.
|
|
168
|
+
|
|
169
|
+
==================
|
|
170
|
+
|
|
171
|
+
Apache-2.0 (intersection-observer):
|
|
172
|
+
The following files embed [intersection-observer](https://github.com/GoogleChromeLabs/intersection-observer) Apache-2.0:
|
|
173
|
+
`/packages/taro-api/src/polyfill/intersection-observer.ts`
|
|
174
|
+
See `/LICENSE.txt` for details of the license.
|
package/dist/api-loader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-loader.js","sources":["../src/api-loader.ts"],"sourcesContent":["export default function (str: string) {\n return `import {\n useAddToFavorites,\n useDidHide,\n useDidShow,\n useError,\n useLaunch,\n useLoad,\n useOptionMenuClick,\n usePageNotFound,\n usePageScroll,\n usePullDownRefresh,\n usePullIntercept,\n useReachBottom,\n useReady,\n useResize,\n useRouter,\n useSaveExitState,\n useShareAppMessage,\n useShareTimeline,\n useTabItemTap,\n useTitleClick,\n useScope,\n useUnhandledRejection,\n useUnload\n} from '@tarojs/plugin-framework-react/dist/runtime'\n${str}\n\ntaro.useAddToFavorites = useAddToFavorites\ntaro.useDidHide = useDidHide\ntaro.useDidShow = useDidShow\ntaro.useError = useError\ntaro.useLaunch = useLaunch\ntaro.useLoad = useLoad\ntaro.useOptionMenuClick = useOptionMenuClick\ntaro.usePageNotFound = usePageNotFound\ntaro.usePageScroll = usePageScroll\ntaro.usePullDownRefresh = usePullDownRefresh\ntaro.usePullIntercept = usePullIntercept\ntaro.useReachBottom = useReachBottom\ntaro.useReady = useReady\ntaro.useResize = useResize\ntaro.useRouter = useRouter\ntaro.useSaveExitState = useSaveExitState\ntaro.useShareAppMessage = useShareAppMessage\ntaro.useShareTimeline = useShareTimeline\ntaro.useTabItemTap = useTabItemTap\ntaro.useTitleClick = useTitleClick\ntaro.useScope = useScope\ntaro.useUnhandledRejection = useUnhandledRejection\ntaro.useUnload = useUnload\n\nexport {\n useAddToFavorites,\n useDidHide,\n useDidShow,\n useError,\n useLaunch,\n useLoad,\n useOptionMenuClick,\n usePageNotFound,\n usePageScroll,\n usePullDownRefresh,\n usePullIntercept,\n useReachBottom,\n useReady,\n useResize,\n useRouter,\n useSaveExitState,\n useShareAppMessage,\n useShareTimeline,\n useTabItemTap,\n useTitleClick,\n useScope,\n useUnhandledRejection,\n useUnload\n}\n`\n}\n"],"names":[],"mappings":";;AAAc,kBAAA,EAAW,GAAW,EAAA;
|
|
1
|
+
{"version":3,"file":"api-loader.js","sources":["../src/api-loader.ts"],"sourcesContent":["export default function (str: string) {\n return `import {\n useAddToFavorites,\n useDidHide,\n useDidShow,\n useError,\n useLaunch,\n useLoad,\n useOptionMenuClick,\n usePageNotFound,\n usePageScroll,\n usePullDownRefresh,\n usePullIntercept,\n useReachBottom,\n useReady,\n useResize,\n useRouter,\n useSaveExitState,\n useShareAppMessage,\n useShareTimeline,\n useTabItemTap,\n useTitleClick,\n useScope,\n useUnhandledRejection,\n useUnload\n} from '@tarojs/plugin-framework-react/dist/runtime'\n${str}\n\ntaro.useAddToFavorites = useAddToFavorites\ntaro.useDidHide = useDidHide\ntaro.useDidShow = useDidShow\ntaro.useError = useError\ntaro.useLaunch = useLaunch\ntaro.useLoad = useLoad\ntaro.useOptionMenuClick = useOptionMenuClick\ntaro.usePageNotFound = usePageNotFound\ntaro.usePageScroll = usePageScroll\ntaro.usePullDownRefresh = usePullDownRefresh\ntaro.usePullIntercept = usePullIntercept\ntaro.useReachBottom = useReachBottom\ntaro.useReady = useReady\ntaro.useResize = useResize\ntaro.useRouter = useRouter\ntaro.useSaveExitState = useSaveExitState\ntaro.useShareAppMessage = useShareAppMessage\ntaro.useShareTimeline = useShareTimeline\ntaro.useTabItemTap = useTabItemTap\ntaro.useTitleClick = useTitleClick\ntaro.useScope = useScope\ntaro.useUnhandledRejection = useUnhandledRejection\ntaro.useUnload = useUnload\n\nexport {\n useAddToFavorites,\n useDidHide,\n useDidShow,\n useError,\n useLaunch,\n useLoad,\n useOptionMenuClick,\n usePageNotFound,\n usePageScroll,\n usePullDownRefresh,\n usePullIntercept,\n useReachBottom,\n useReady,\n useResize,\n useRouter,\n useSaveExitState,\n useShareAppMessage,\n useShareTimeline,\n useTabItemTap,\n useTitleClick,\n useScope,\n useUnhandledRejection,\n useUnload\n}\n`\n}\n"],"names":[],"mappings":";;AAAc,kBAAA,EAAW,GAAW,EAAA;IAClC,OAAO,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;EAyBP,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmDJ,CAAA;AACD;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -43,7 +43,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
43
43
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
44
44
|
PERFORMANCE OF THIS SOFTWARE.
|
|
45
45
|
***************************************************************************** */
|
|
46
|
-
/* global Reflect, Promise */
|
|
46
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
@@ -54,7 +54,12 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
54
54
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
55
55
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
56
56
|
});
|
|
57
|
-
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
60
|
+
var e = new Error(message);
|
|
61
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
62
|
+
};
|
|
58
63
|
|
|
59
64
|
function apiLoader (str) {
|
|
60
65
|
return `import {
|
|
@@ -227,7 +232,20 @@ class App extends React.Component {
|
|
|
227
232
|
if (framework === 'nerv') {
|
|
228
233
|
Object.assign(loaderMeta, nervMeta);
|
|
229
234
|
}
|
|
230
|
-
if (
|
|
235
|
+
if (framework === 'solid') {
|
|
236
|
+
Object.assign(loaderMeta, {
|
|
237
|
+
creator: 'createSolidApp',
|
|
238
|
+
frameworkArgs: 'config',
|
|
239
|
+
importFrameworkStatement: '',
|
|
240
|
+
importFrameworkName: '',
|
|
241
|
+
mockAppStatement: `
|
|
242
|
+
function App(props) {
|
|
243
|
+
return null
|
|
244
|
+
}
|
|
245
|
+
`,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
if (process.env.TARO_PLATFORM === 'web') {
|
|
231
249
|
if (framework === 'react') {
|
|
232
250
|
const react = require('react');
|
|
233
251
|
const majorVersion = Number((react.version || '18').split('.')[0]);
|
|
@@ -275,7 +293,6 @@ function setTaroApi() {
|
|
|
275
293
|
enforce: 'pre',
|
|
276
294
|
config: () => ({
|
|
277
295
|
optimizeDeps: {
|
|
278
|
-
force: true,
|
|
279
296
|
esbuildOptions: {
|
|
280
297
|
plugins: [
|
|
281
298
|
{
|
|
@@ -317,7 +334,7 @@ function esbuildExclude(framework) {
|
|
|
317
334
|
enforce: 'pre',
|
|
318
335
|
config: () => ({
|
|
319
336
|
optimizeDeps: {
|
|
320
|
-
exclude: ['react', 'preact']
|
|
337
|
+
exclude: ['react', 'preact', 'solid-js']
|
|
321
338
|
}
|
|
322
339
|
})
|
|
323
340
|
};
|
|
@@ -349,8 +366,13 @@ function aliasPlugin$1(ctx, framework) {
|
|
|
349
366
|
config(config) {
|
|
350
367
|
var _a;
|
|
351
368
|
const alias = [
|
|
352
|
-
{ find: /react-dom$/, replacement: '@tarojs/react' }
|
|
369
|
+
{ find: /react-dom$/, replacement: '@tarojs/react' },
|
|
353
370
|
];
|
|
371
|
+
const mainFields = ['unpkg', ...helper.defaultMainFields];
|
|
372
|
+
const resolveOptions = {
|
|
373
|
+
basedir: process.cwd(),
|
|
374
|
+
mainFields,
|
|
375
|
+
};
|
|
354
376
|
const isProd = config.mode === 'production';
|
|
355
377
|
// TODO:harmony 目前会导致部分包用 production 版本,部分用 development 版本,导致许多 api 报错
|
|
356
378
|
const isHarmony = ctx.runOpts.options.platform === 'harmony';
|
|
@@ -362,7 +384,7 @@ function aliasPlugin$1(ctx, framework) {
|
|
|
362
384
|
alias.push({ find: /react\/jsx-runtime$/, replacement: 'react/cjs/react-jsx-runtime.production.min.js' });
|
|
363
385
|
// 在React18中,使用了exports字段约定了模块暴露路径,其中并未暴露 ./cjs/ 。这将使上面的alias在编译时报错。相当的tricky。
|
|
364
386
|
// Why writeJson? prebundle will load package.json via readFile to check exports property.
|
|
365
|
-
const reactPkgPath =
|
|
387
|
+
const reactPkgPath = helper.resolveSync('react/package.json', resolveOptions);
|
|
366
388
|
if (reactPkgPath) {
|
|
367
389
|
const reactPkg = require('react/package.json');
|
|
368
390
|
const reactVersion = (reactPkg.version || '');
|
|
@@ -382,6 +404,23 @@ function aliasPlugin$1(ctx, framework) {
|
|
|
382
404
|
}
|
|
383
405
|
};
|
|
384
406
|
}
|
|
407
|
+
else if (framework === 'solid') {
|
|
408
|
+
return {
|
|
409
|
+
name: 'taro-solid:alias',
|
|
410
|
+
config() {
|
|
411
|
+
const reconcilerName = '@tarojs/plugin-framework-react/dist/reconciler';
|
|
412
|
+
const alias = [
|
|
413
|
+
{ find: 'solid-js/web', replacement: reconcilerName },
|
|
414
|
+
{ find: 'react/jsx-runtime', replacement: reconcilerName },
|
|
415
|
+
];
|
|
416
|
+
return {
|
|
417
|
+
resolve: {
|
|
418
|
+
alias
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
}
|
|
385
424
|
return [];
|
|
386
425
|
}
|
|
387
426
|
|
|
@@ -413,6 +452,11 @@ function aliasPlugin(ctx, framework) {
|
|
|
413
452
|
const alias = [
|
|
414
453
|
{ find: /react-dom$/, replacement: '@tarojs/react' }
|
|
415
454
|
];
|
|
455
|
+
const mainFields = ['unpkg', ...helper.defaultMainFields];
|
|
456
|
+
const resolveOptions = {
|
|
457
|
+
basedir: process.cwd(),
|
|
458
|
+
mainFields,
|
|
459
|
+
};
|
|
416
460
|
const isProd = config.mode === 'production';
|
|
417
461
|
// TODO:harmony 目前会导致部分包用 production 版本,部分用 development 版本,导致许多 api 报错
|
|
418
462
|
const isHarmony = ctx.runOpts.options.platform === 'harmony';
|
|
@@ -424,7 +468,7 @@ function aliasPlugin(ctx, framework) {
|
|
|
424
468
|
alias.push({ find: /react\/jsx-runtime$/, replacement: 'react/cjs/react-jsx-runtime.production.min.js' });
|
|
425
469
|
// 在React18中,使用了exports字段约定了模块暴露路径,其中并未暴露 ./cjs/ 。这将使上面的alias在编译时报错。相当的tricky。
|
|
426
470
|
// Why writeJson? prebundle will load package.json via readFile to check exports property.
|
|
427
|
-
const reactPkgPath =
|
|
471
|
+
const reactPkgPath = helper.resolveSync('react/package.json', resolveOptions);
|
|
428
472
|
if (reactPkgPath) {
|
|
429
473
|
const reactPkg = require('react/package.json');
|
|
430
474
|
const reactVersion = (reactPkg.version || '');
|
|
@@ -444,6 +488,23 @@ function aliasPlugin(ctx, framework) {
|
|
|
444
488
|
}
|
|
445
489
|
};
|
|
446
490
|
}
|
|
491
|
+
else if (framework === 'solid') {
|
|
492
|
+
return {
|
|
493
|
+
name: 'taro-solid:alias',
|
|
494
|
+
config() {
|
|
495
|
+
const reconcilerName = '@tarojs/plugin-framework-react/dist/reconciler';
|
|
496
|
+
const alias = [
|
|
497
|
+
{ find: 'solid-js/web', replacement: reconcilerName },
|
|
498
|
+
{ find: 'react/jsx-runtime', replacement: reconcilerName },
|
|
499
|
+
];
|
|
500
|
+
return {
|
|
501
|
+
resolve: {
|
|
502
|
+
alias
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
};
|
|
507
|
+
}
|
|
447
508
|
return [];
|
|
448
509
|
}
|
|
449
510
|
|
|
@@ -455,23 +516,58 @@ function modifyH5WebpackChain(ctx, framework, chain) {
|
|
|
455
516
|
const externals = {};
|
|
456
517
|
if (isBuildNativeComp) {
|
|
457
518
|
// Note: 该模式不支持 prebundle 优化,不必再处理
|
|
458
|
-
externals.react =
|
|
459
|
-
|
|
519
|
+
externals.react = {
|
|
520
|
+
commonjs: 'react',
|
|
521
|
+
commonjs2: 'react',
|
|
522
|
+
amd: 'react',
|
|
523
|
+
root: 'React'
|
|
524
|
+
};
|
|
525
|
+
externals['react-dom'] = {
|
|
526
|
+
commonjs: 'react-dom',
|
|
527
|
+
commonjs2: 'react-dom',
|
|
528
|
+
amd: 'react-dom',
|
|
529
|
+
root: 'ReactDOM'
|
|
530
|
+
};
|
|
460
531
|
if (framework === 'preact') {
|
|
461
532
|
externals.preact = 'preact';
|
|
462
533
|
}
|
|
534
|
+
chain.merge({
|
|
535
|
+
externalsType: 'umd'
|
|
536
|
+
});
|
|
463
537
|
}
|
|
464
538
|
chain.merge({
|
|
465
539
|
externals,
|
|
466
540
|
module: {
|
|
467
541
|
rule: {
|
|
468
|
-
'process-import-taro': {
|
|
542
|
+
'process-import-taro-h5': {
|
|
469
543
|
test: helper.REG_TARO_H5,
|
|
470
544
|
loader: require.resolve('./api-loader'),
|
|
471
545
|
},
|
|
472
546
|
},
|
|
473
547
|
},
|
|
474
548
|
});
|
|
549
|
+
chain.merge({
|
|
550
|
+
externals,
|
|
551
|
+
module: {
|
|
552
|
+
rule: {
|
|
553
|
+
'process-import-taro-harmony-hybrid': {
|
|
554
|
+
test: /taro-platform-harmony-hybrid[\\/]dist[\\/]api[\\/]apis[\\/]taro/,
|
|
555
|
+
loader: require.resolve('./api-loader')
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
},
|
|
559
|
+
});
|
|
560
|
+
chain.merge({
|
|
561
|
+
externals,
|
|
562
|
+
module: {
|
|
563
|
+
rule: {
|
|
564
|
+
'process-import-taro-harmony-hybrid': {
|
|
565
|
+
test: /taro-platform-harmony-hybrid[\\/]dist[\\/]api[\\/]apis[\\/]taro/,
|
|
566
|
+
loader: require.resolve('./api-loader')
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
},
|
|
570
|
+
});
|
|
475
571
|
}
|
|
476
572
|
function setLoader$2(framework, chain) {
|
|
477
573
|
function customizer(object = '', sources = '') {
|
|
@@ -498,6 +594,23 @@ function setPlugin(ctx, framework, chain) {
|
|
|
498
594
|
chain.plugin('fastRefreshPlugin').use(require('@prefresh/webpack'));
|
|
499
595
|
}
|
|
500
596
|
}
|
|
597
|
+
const mainFields = ['unpkg', ...helper.defaultMainFields];
|
|
598
|
+
const resolveOptions = {
|
|
599
|
+
basedir: process.cwd(),
|
|
600
|
+
mainFields,
|
|
601
|
+
};
|
|
602
|
+
if (framework === 'solid') {
|
|
603
|
+
const reconcilerName = '@tarojs/plugin-framework-react/dist/reconciler';
|
|
604
|
+
const alias = chain.resolve.alias;
|
|
605
|
+
alias.set(reconcilerName, helper.resolveSync('solid-js/web', resolveOptions));
|
|
606
|
+
// Note: 本地 link 调试时,避免 solid 重复打包
|
|
607
|
+
alias.set('solid-js$', helper.resolveSync('solid-js', resolveOptions));
|
|
608
|
+
}
|
|
609
|
+
else if (framework === 'react') {
|
|
610
|
+
const alias = chain.resolve.alias;
|
|
611
|
+
// Note: 本地 link 调试时,避免 react 重复打包
|
|
612
|
+
alias.set('react$', helper.resolveSync('react', resolveOptions));
|
|
613
|
+
}
|
|
501
614
|
}
|
|
502
615
|
|
|
503
616
|
function modifyHarmonyWebpackChain(ctx, framework, chain) {
|
|
@@ -508,6 +621,11 @@ function setAlias$2(ctx, framework, chain) {
|
|
|
508
621
|
var _a;
|
|
509
622
|
const config = ctx.initialConfig;
|
|
510
623
|
const alias = chain.resolve.alias;
|
|
624
|
+
const mainFields = ['unpkg', ...helper.defaultMainFields];
|
|
625
|
+
const resolveOptions = {
|
|
626
|
+
basedir: process.cwd(),
|
|
627
|
+
mainFields,
|
|
628
|
+
};
|
|
511
629
|
if (framework === 'react') {
|
|
512
630
|
alias.set('react-dom$', '@tarojs/react');
|
|
513
631
|
alias.set('react-dom/client$', '@tarojs/react');
|
|
@@ -516,14 +634,14 @@ function setAlias$2(ctx, framework, chain) {
|
|
|
516
634
|
if (!isProd && ((_a = config.harmony) === null || _a === void 0 ? void 0 : _a.debugReact) !== true) {
|
|
517
635
|
// 不是生产环境,且没有设置 debugReact,则使用压缩版本的 react 依赖,减少体积
|
|
518
636
|
// 兼容pnpm workspace
|
|
519
|
-
const reactModulePath =
|
|
637
|
+
const reactModulePath = helper.resolveSync('react', resolveOptions);
|
|
520
638
|
const newFilePath = path.join(path.dirname(reactModulePath), 'cjs', 'react.production.min.js');
|
|
521
639
|
alias.set('react-reconciler$', 'react-reconciler/cjs/react-reconciler.production.min.js');
|
|
522
640
|
alias.set('react$', newFilePath);
|
|
523
641
|
alias.set('react/jsx-runtime$', 'react/cjs/react-jsx-runtime.production.min.js');
|
|
524
642
|
// 在React18中,使用了exports字段约定了模块暴露路径,其中并未暴露 ./cjs/ 。这将使上面的alias在编译时报错。相当的tricky。
|
|
525
643
|
// Why writeJson? prebundle will load package.json via readFile to check exports property.
|
|
526
|
-
const reactPkgPath =
|
|
644
|
+
const reactPkgPath = helper.resolveSync('react/package.json', resolveOptions);
|
|
527
645
|
if (reactPkgPath) {
|
|
528
646
|
const reactPkg = require('react/package.json');
|
|
529
647
|
const reactVersion = reactPkg.version || '';
|
|
@@ -536,6 +654,11 @@ function setAlias$2(ctx, framework, chain) {
|
|
|
536
654
|
}
|
|
537
655
|
}
|
|
538
656
|
}
|
|
657
|
+
else if (framework === 'solid') {
|
|
658
|
+
const reconcilerName = '@tarojs/plugin-framework-react/dist/reconciler';
|
|
659
|
+
alias.set('solid-js/web', reconcilerName);
|
|
660
|
+
alias.set('react/jsx-runtime', reconcilerName);
|
|
661
|
+
}
|
|
539
662
|
}
|
|
540
663
|
function setLoader$1(framework, chain) {
|
|
541
664
|
chain.plugin('mainPlugin').tap((args) => {
|
|
@@ -552,6 +675,11 @@ function setAlias$1(ctx, framework, chain) {
|
|
|
552
675
|
var _a;
|
|
553
676
|
const config = ctx.initialConfig;
|
|
554
677
|
const alias = chain.resolve.alias;
|
|
678
|
+
const mainFields = ['unpkg', ...helper.defaultMainFields];
|
|
679
|
+
const resolveOptions = {
|
|
680
|
+
basedir: process.cwd(),
|
|
681
|
+
mainFields,
|
|
682
|
+
};
|
|
555
683
|
if (framework === 'react') {
|
|
556
684
|
alias.set('react-dom$', '@tarojs/react');
|
|
557
685
|
alias.set('react-dom/client$', '@tarojs/react');
|
|
@@ -560,14 +688,14 @@ function setAlias$1(ctx, framework, chain) {
|
|
|
560
688
|
if (!isProd && ((_a = config.mini) === null || _a === void 0 ? void 0 : _a.debugReact) !== true) {
|
|
561
689
|
// 不是生产环境,且没有设置 debugReact,则使用压缩版本的 react 依赖,减少体积
|
|
562
690
|
// 兼容pnpm workspace
|
|
563
|
-
const reactModulePath =
|
|
691
|
+
const reactModulePath = helper.resolveSync('react', resolveOptions);
|
|
564
692
|
const newFilePath = path.join(path.dirname(reactModulePath), 'cjs', 'react.production.min.js');
|
|
565
693
|
alias.set('react-reconciler$', 'react-reconciler/cjs/react-reconciler.production.min.js');
|
|
566
694
|
alias.set(/^(?!.*mobx-react$).*react$/, newFilePath);
|
|
567
695
|
alias.set('react/jsx-runtime$', 'react/cjs/react-jsx-runtime.production.min.js');
|
|
568
696
|
// 在React18中,使用了exports字段约定了模块暴露路径,其中并未暴露 ./cjs/ 。这将使上面的alias在编译时报错。相当的tricky。
|
|
569
697
|
// Why writeJson? prebundle will load package.json via readFile to check exports property.
|
|
570
|
-
const reactPkgPath =
|
|
698
|
+
const reactPkgPath = helper.resolveSync('react/package.json', resolveOptions);
|
|
571
699
|
if (reactPkgPath) {
|
|
572
700
|
const reactPkg = require('react/package.json');
|
|
573
701
|
const reactVersion = reactPkg.version || '';
|
|
@@ -580,6 +708,12 @@ function setAlias$1(ctx, framework, chain) {
|
|
|
580
708
|
}
|
|
581
709
|
}
|
|
582
710
|
}
|
|
711
|
+
else if (framework === 'solid') {
|
|
712
|
+
const reconcilerName = '@tarojs/plugin-framework-react/dist/reconciler';
|
|
713
|
+
alias.set('solid-js/web', reconcilerName);
|
|
714
|
+
// Note: 本地 link 调试时,避免 solid 重复打包
|
|
715
|
+
alias.set('solid-js$', helper.resolveSync('solid-js', resolveOptions));
|
|
716
|
+
}
|
|
583
717
|
}
|
|
584
718
|
function setLoader(framework, chain) {
|
|
585
719
|
chain.plugin('miniPlugin').tap((args) => {
|
|
@@ -598,12 +732,7 @@ var index = (ctx) => {
|
|
|
598
732
|
ctx.modifyWebpackChain(({ chain }) => {
|
|
599
733
|
// 通用
|
|
600
734
|
setAlias(framework, chain);
|
|
601
|
-
|
|
602
|
-
const config = args[0];
|
|
603
|
-
config.__TARO_FRAMEWORK__ = `"${framework}"`;
|
|
604
|
-
return args;
|
|
605
|
-
});
|
|
606
|
-
if (shared.isWebPlatform()) {
|
|
735
|
+
if (process.env.TARO_PLATFORM === 'web') {
|
|
607
736
|
// H5
|
|
608
737
|
modifyH5WebpackChain(ctx, framework, chain);
|
|
609
738
|
}
|
|
@@ -645,6 +774,12 @@ var index = (ctx) => {
|
|
|
645
774
|
contents: require('./api-loader')(content),
|
|
646
775
|
};
|
|
647
776
|
});
|
|
777
|
+
build.onLoad({ filter: /taro-platform-harmony-hybrid[\\/]dist[\\/]api[\\/]apis[\\/]taro/ }, ({ path }) => {
|
|
778
|
+
const content = helper.fs.readFileSync(path).toString();
|
|
779
|
+
return {
|
|
780
|
+
contents: require('./api-loader')(content)
|
|
781
|
+
};
|
|
782
|
+
});
|
|
648
783
|
},
|
|
649
784
|
};
|
|
650
785
|
prebundleOptions.esbuild || (prebundleOptions.esbuild = {});
|
|
@@ -656,7 +791,7 @@ var index = (ctx) => {
|
|
|
656
791
|
compiler.vitePlugins || (compiler.vitePlugins = []);
|
|
657
792
|
compiler.vitePlugins.push(viteCommonPlugin(framework));
|
|
658
793
|
compiler.vitePlugins.push(VitePresetPlugin(framework));
|
|
659
|
-
if (
|
|
794
|
+
if (process.env.TARO_PLATFORM === 'web') {
|
|
660
795
|
// H5
|
|
661
796
|
compiler.vitePlugins.push(h5iVitePlugin(ctx, framework));
|
|
662
797
|
}
|
|
@@ -684,6 +819,9 @@ function setAlias(framework, chain) {
|
|
|
684
819
|
alias.set('react$', 'nervjs');
|
|
685
820
|
alias.set('react-dom$', 'nervjs');
|
|
686
821
|
break;
|
|
822
|
+
case 'solid':
|
|
823
|
+
alias.set('react/jsx-runtime', 'solid-js/h/jsx-runtime');
|
|
824
|
+
break;
|
|
687
825
|
}
|
|
688
826
|
}
|
|
689
827
|
function VitePresetPlugin(framework) {
|
|
@@ -717,17 +855,11 @@ function viteCommonPlugin(framework) {
|
|
|
717
855
|
{ find: 'react/jsx-runtime', replacement: 'preact/jsx-runtime' },
|
|
718
856
|
]
|
|
719
857
|
: [];
|
|
858
|
+
if (framework === 'solid') {
|
|
859
|
+
const reconcilerName = '@tarojs/plugin-framework-react/dist/reconciler';
|
|
860
|
+
alias.push({ find: 'react/jsx-runtime', replacement: reconcilerName });
|
|
861
|
+
}
|
|
720
862
|
return {
|
|
721
|
-
optimizeDeps: {
|
|
722
|
-
esbuildOptions: {
|
|
723
|
-
define: {
|
|
724
|
-
__TARO_FRAMEWORK__: `"${framework}"`
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
},
|
|
728
|
-
define: {
|
|
729
|
-
__TARO_FRAMEWORK__: `"${framework}"`,
|
|
730
|
-
},
|
|
731
863
|
resolve: {
|
|
732
864
|
alias,
|
|
733
865
|
},
|