@tarojs/plugin-inject 4.0.0-beta.9 → 4.0.0-beta.90
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/dist/index.js +0 -5
- package/dist/index.js.map +1 -1
- package/dist/runtime.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -28,11 +28,6 @@ var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
|
28
28
|
|
|
29
29
|
var index = (ctx, options) => {
|
|
30
30
|
const fs = ctx.helper.fs;
|
|
31
|
-
ctx.modifyWebpackChain(({ chain }) => {
|
|
32
|
-
if (options.componentsMap) {
|
|
33
|
-
chain.optimization.providedExports(false);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
31
|
ctx.registerMethod({
|
|
37
32
|
name: 'onSetupClose',
|
|
38
33
|
fn(platform) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["\nimport { esbuild } from '@tarojs/helper'\nimport { isArray, isFunction, isObject, isString } from '@tarojs/shared'\nimport * as path from 'path'\n\nimport type { IPluginContext, TaroPlatformBase } from '@tarojs/service'\n\ntype VoidComponents = Set<string>\ntype NestElements = Map<string, number>\n\nexport interface IOptions {\n voidComponents: string[] | ((list: VoidComponents) => VoidComponents)\n nestElements: Record<string, number> | ((elem: NestElements) => NestElements)\n components: Record<string, Record<string, any>>\n componentsMap: Record<string, string>\n syncApis: string[]\n asyncApis: string[]\n thirdPartyComponents: Record<string, Record<string, any>>\n}\n\nexport default (ctx: IPluginContext, options: IOptions) => {\n const fs = ctx.helper.fs\n\n ctx.
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["\nimport { esbuild } from '@tarojs/helper'\nimport { isArray, isFunction, isObject, isString } from '@tarojs/shared'\nimport * as path from 'path'\n\nimport type { IPluginContext, TaroPlatformBase } from '@tarojs/service'\n\ntype VoidComponents = Set<string>\ntype NestElements = Map<string, number>\n\nexport interface IOptions {\n voidComponents: string[] | ((list: VoidComponents) => VoidComponents)\n nestElements: Record<string, number> | ((elem: NestElements) => NestElements)\n components: Record<string, Record<string, any>>\n componentsMap: Record<string, string>\n syncApis: string[]\n asyncApis: string[]\n thirdPartyComponents: Record<string, Record<string, any>>\n}\n\nexport default (ctx: IPluginContext, options: IOptions) => {\n const fs = ctx.helper.fs\n\n ctx.registerMethod({\n name: 'onSetupClose',\n fn (platform: TaroPlatformBase) {\n const {\n voidComponents,\n nestElements,\n components,\n syncApis,\n asyncApis,\n componentsMap,\n thirdPartyComponents\n } = options\n\n const template = platform.template\n if (!template) return\n\n if (isArray(voidComponents)) {\n voidComponents.forEach(el => template.voidElements.add(el))\n } else if (isFunction(voidComponents)) {\n template.voidElements = voidComponents(template.voidElements)\n }\n\n if (isObject<NestElements>(nestElements)) {\n for (const key in nestElements) {\n template.nestElements.set(key, nestElements[key])\n }\n } else if (isFunction(nestElements)) {\n template.nestElements = nestElements(template.nestElements)\n }\n\n if (components || syncApis || asyncApis || componentsMap) {\n injectRuntimePath(platform)\n\n if (components) {\n template.mergeComponents(ctx, components)\n }\n\n if (componentsMap) {\n injectComponentsReact(fs, platform.taroComponentsPath, componentsMap)\n platform.taroComponentsPath = `@tarojs/plugin-inject/dist/components-react`\n }\n\n injectComponents(fs, components)\n injectApis(fs, syncApis, asyncApis)\n }\n\n if (thirdPartyComponents) {\n template.mergeThirdPartyComponents(thirdPartyComponents)\n }\n }\n })\n}\n\nfunction injectRuntimePath (platform: TaroPlatformBase) {\n const injectedPath = `@tarojs/plugin-inject/dist/runtime`\n if (isArray(platform.runtimePath)) {\n platform.runtimePath.push(injectedPath)\n } else if (isString(platform.runtimePath)) {\n platform.runtimePath = [platform.runtimePath, injectedPath]\n }\n}\n\nfunction injectComponentsReact (fs, taroComponentsPath, componentsMap) {\n const filePath = path.resolve(__dirname, '../dist/components-react.js')\n fs.writeFileSync(filePath, `\nexport * from '${taroComponentsPath}'\n${Object.keys(componentsMap).map((key) => `export const ${key} = '${componentsMap[key]}'`).join('\\n')}\n`)\n // 提前使用 esbuild 进行 bundle,避免 Webpack 分析过程中的错误,#13299 #14520\n const result = esbuild.buildSync({\n entryPoints: [filePath],\n bundle: true,\n write: false,\n format: 'esm',\n })\n fs.writeFileSync(filePath, result.outputFiles[0].text)\n}\n\nfunction injectComponents (fs, components) {\n fs.writeFileSync(path.resolve(__dirname, '../dist/components.js'), `\nexport const components = ${components ? JSON.stringify(components) : JSON.stringify({})};\n`)\n}\n\nfunction injectApis (fs, syncApis, asyncApis) {\n fs.writeFileSync(path.resolve(__dirname, '../dist/apis-list.js'), `\nexport const noPromiseApis = new Set(${syncApis ? JSON.stringify(syncApis) : JSON.stringify([])});\nexport const needPromiseApis = new Set(${asyncApis ? JSON.stringify(asyncApis) : JSON.stringify([])});\n`)\n}\n"],"names":["isArray","isFunction","isObject","isString","path","esbuild"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,YAAe,CAAC,GAAmB,EAAE,OAAiB,KAAI;AACxD,IAAA,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAA;IAExB,GAAG,CAAC,cAAc,CAAC;AACjB,QAAA,IAAI,EAAE,cAAc;AACpB,QAAA,EAAE,CAAE,QAA0B,EAAA;AAC5B,YAAA,MAAM,EACJ,cAAc,EACd,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,SAAS,EACT,aAAa,EACb,oBAAoB,EACrB,GAAG,OAAO,CAAA;AAEX,YAAA,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAA;AAClC,YAAA,IAAI,CAAC,QAAQ;gBAAE,OAAM;AAErB,YAAA,IAAIA,cAAO,CAAC,cAAc,CAAC,EAAE;AAC3B,gBAAA,cAAc,CAAC,OAAO,CAAC,EAAE,IAAI,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,C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CAACD,eAAI,CAAC,OAAO,CAAC,SAAS,EAAE,uBAAuB,CAAC,EAAE,CAAA;AACzC,0BAAA,EAAA,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;AACvF,CAAA,CAAC,CAAA;AACF,CAAC;AAED,SAAS,UAAU,CAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAA;IAC1C,EAAE,CAAC,aAAa,CAACA,eAAI,CAAC,OAAO,CAAC,SAAS,EAAE,sBAAsB,CAAC,EAAE,CAAA;AAC7B,qCAAA,EAAA,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;AACtD,uCAAA,EAAA,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;AAClG,CAAA,CAAC,CAAA;AACF;;;;"}
|
package/dist/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sources":["../src/runtime.ts"],"sourcesContent":["import { mergeInternalComponents, mergeReconciler, processApis } from '@tarojs/shared'\n\nimport { needPromiseApis, noPromiseApis } from './apis-list'\nimport { components } from './components'\n\nconst hostConfig = {\n initNativeApi (taro) {\n const global = taro.miniGlobal\n processApis(taro, global, {\n noPromiseApis,\n needPromiseApis,\n isOnlyPromisify: true\n })\n }\n}\n\
|
|
1
|
+
{"version":3,"file":"runtime.js","sources":["../src/runtime.ts"],"sourcesContent":["import { mergeInternalComponents, mergeReconciler, processApis } from '@tarojs/shared'\n\nimport { needPromiseApis, noPromiseApis } from './apis-list'\nimport { components } from './components'\n\nconst hostConfig = {\n initNativeApi (taro) {\n const global = taro.miniGlobal\n processApis(taro, global, {\n noPromiseApis,\n needPromiseApis,\n isOnlyPromisify: true\n })\n }\n}\n\nmergeReconciler(hostConfig)\nmergeInternalComponents(components)\n"],"names":[],"mappings":";;;;AAKA,MAAM,UAAU,GAAG;AACjB,IAAA,aAAa,CAAE,IAAI,EAAA;AACjB,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAA;AAC9B,QAAA,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE;YACxB,aAAa;YACb,eAAe;AACf,YAAA,eAAe,EAAE,IAAI;AACtB,SAAA,CAAC,CAAA;KACH;CACF,CAAA;AAED,eAAe,CAAC,UAAU,CAAC,CAAA;AAC3B,uBAAuB,CAAC,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/plugin-inject",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.90",
|
|
4
4
|
"description": "Taro 小程序端平台中间层插件",
|
|
5
5
|
"author": "luckyadam",
|
|
6
6
|
"homepage": "https://github.com/nervjs/taro",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"url": "https://github.com/NervJS/taro/issues"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@tarojs/service": "4.0.0-beta.
|
|
25
|
-
"@tarojs/
|
|
26
|
-
"@tarojs/
|
|
24
|
+
"@tarojs/service": "4.0.0-beta.90",
|
|
25
|
+
"@tarojs/shared": "4.0.0-beta.90",
|
|
26
|
+
"@tarojs/helper": "4.0.0-beta.90"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"rollup": "^2.79.0",
|