@tarojs/plugin-inject 3.8.0-canary.0 → 4.0.0-alpha.2
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/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime.js.map +1 -1
- package/package.json +4 -3
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/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var helper = require('@tarojs/helper');
|
|
5
6
|
var shared = require('@tarojs/shared');
|
|
6
7
|
var path = require('path');
|
|
7
8
|
|
|
@@ -37,6 +38,8 @@ var index = (ctx, options) => {
|
|
|
37
38
|
fn(platform) {
|
|
38
39
|
const { voidComponents, nestElements, components, syncApis, asyncApis, componentsMap, thirdPartyComponents } = options;
|
|
39
40
|
const template = platform.template;
|
|
41
|
+
if (!template)
|
|
42
|
+
return;
|
|
40
43
|
if (shared.isArray(voidComponents)) {
|
|
41
44
|
voidComponents.forEach(el => template.voidElements.add(el));
|
|
42
45
|
}
|
|
@@ -79,10 +82,19 @@ function injectRuntimePath(platform) {
|
|
|
79
82
|
}
|
|
80
83
|
}
|
|
81
84
|
function injectComponentsReact(fs, taroComponentsPath, componentsMap) {
|
|
82
|
-
|
|
85
|
+
const filePath = path__namespace.resolve(__dirname, '../dist/components-react.js');
|
|
86
|
+
fs.writeFileSync(filePath, `
|
|
83
87
|
export * from '${taroComponentsPath}'
|
|
84
88
|
${Object.keys(componentsMap).map((key) => `export const ${key} = '${componentsMap[key]}'`).join('\n')}
|
|
85
89
|
`);
|
|
90
|
+
// 提前使用 esbuild 进行 bundle,避免 Webpack 分析过程中的错误,#13299 #14520
|
|
91
|
+
const result = helper.esbuild.buildSync({
|
|
92
|
+
entryPoints: [filePath],
|
|
93
|
+
bundle: true,
|
|
94
|
+
write: false,
|
|
95
|
+
format: 'esm',
|
|
96
|
+
});
|
|
97
|
+
fs.writeFileSync(filePath, result.outputFiles[0].text);
|
|
86
98
|
}
|
|
87
99
|
function injectComponents(fs, components) {
|
|
88
100
|
fs.writeFileSync(path__namespace.resolve(__dirname, '../dist/components.js'), `
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["\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.modifyWebpackChain(({ chain }) => {\n if(options.componentsMap){\n chain.optimization.providedExports(false)\n }\n })\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\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
|
|
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.modifyWebpackChain(({ chain }) => {\n if (options.componentsMap) {\n chain.optimization.providedExports(false)\n }\n })\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,kBAAkB,CAAC,CAAC,EAAE,KAAK,EAAE,KAAI;QACnC,IAAI,OAAO,CAAC,aAAa,EAAE;AACzB,YAAA,KAAK,CAAC,YAAY,CAAC,eAAe,CAAC,KAAK,CAAC,CAAA;AAC1C,SAAA;AACH,KAAC,CAAC,CAAA;IAEF,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,YAA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F,IAAA,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;AACxD,CAAC;AAED,SAAS,gBAAgB,CAAE,EAAE,EAAE,UAAU,EAAA;IACvC,EAAE,CAAC,aAAa,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\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;AAGD,eAAe,CAAC,UAAU,CAAC,CAAA;AAC3B,uBAAuB,CAAC,UAAU,CAAC"}
|
|
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\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;AAGD,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": "
|
|
3
|
+
"version": "4.0.0-alpha.2",
|
|
4
4
|
"description": "Taro 小程序端平台中间层插件",
|
|
5
5
|
"author": "luckyadam",
|
|
6
6
|
"homepage": "https://github.com/nervjs/taro",
|
|
@@ -21,8 +21,9 @@
|
|
|
21
21
|
"url": "https://github.com/NervJS/taro/issues"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@tarojs/
|
|
25
|
-
"@tarojs/
|
|
24
|
+
"@tarojs/shared": "4.0.0-alpha.2",
|
|
25
|
+
"@tarojs/helper": "4.0.0-alpha.2",
|
|
26
|
+
"@tarojs/service": "4.0.0-alpha.2"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
29
|
"rollup": "^2.79.0",
|