@tarojs/plugin-http 3.6.6-alpha.1 → 3.6.6
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 +15 -0
- package/package.json +4 -4
- package/src/index.ts +17 -1
package/dist/index.js
CHANGED
|
@@ -26,6 +26,21 @@ var index = (ctx, options) => {
|
|
|
26
26
|
((_b = options.disabledBlob) !== null && _b !== void 0 ? _b : true) && ((_d = args[0]).Blob || (_d.Blob = [runtimeAlias, 'Blob']));
|
|
27
27
|
return args;
|
|
28
28
|
});
|
|
29
|
+
if (ctx.initialConfig.compiler === 'webpack4' || (shared.isObject(ctx.initialConfig.compiler) && ctx.initialConfig.compiler.type === 'webpack4')) {
|
|
30
|
+
// taro webpack4 中, 未正确识别到 axios package.json 中的 browser 字段, 以致于打包进入了 node 相关的代码(https://github.com/axios/axios/blob/59eb99183546d822bc27e881f5dcd748daa04173/package.json#L128-L132)
|
|
31
|
+
const inAxiosReg = /(\/|\\)(node_modules)(\/|\\)(axios)(\/|\\)/;
|
|
32
|
+
chain.merge({
|
|
33
|
+
externals: [
|
|
34
|
+
(context, request, callback) => {
|
|
35
|
+
if (inAxiosReg.test(context) && request.includes('http.js')) {
|
|
36
|
+
// 将 http 适配器从源码里干掉 https://github.com/axios/axios/blob/59eb99183546d822bc27e881f5dcd748daa04173/lib/adapters/adapters.js#L2
|
|
37
|
+
return callback(null, 'var undefined');
|
|
38
|
+
}
|
|
39
|
+
callback();
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
});
|
|
43
|
+
}
|
|
29
44
|
}
|
|
30
45
|
});
|
|
31
46
|
ctx.registerMethod({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/plugin-http",
|
|
3
|
-
"version": "3.6.6
|
|
3
|
+
"version": "3.6.6",
|
|
4
4
|
"description": "Taro 小程序端支持使用 web 请求 的插件",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://github.com/NervJS/taro#readme",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@tarojs/runtime": "3.6.6
|
|
27
|
-
"@tarojs/service": "3.6.6
|
|
28
|
-
"@tarojs/shared": "3.6.6
|
|
26
|
+
"@tarojs/runtime": "3.6.6",
|
|
27
|
+
"@tarojs/service": "3.6.6",
|
|
28
|
+
"@tarojs/shared": "3.6.6"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@rollup/plugin-json": "^4.1.0",
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isArray, isString } from '@tarojs/shared'
|
|
1
|
+
import { isArray, isObject, isString } from '@tarojs/shared'
|
|
2
2
|
import path from 'path'
|
|
3
3
|
|
|
4
4
|
import { name as packageName } from '../package.json'
|
|
@@ -35,6 +35,22 @@ export default (ctx: IPluginContext, options: IOptions) => {
|
|
|
35
35
|
|
|
36
36
|
return args
|
|
37
37
|
})
|
|
38
|
+
|
|
39
|
+
if (ctx.initialConfig.compiler === 'webpack4' || (isObject<boolean>(ctx.initialConfig.compiler) && ctx.initialConfig.compiler.type === 'webpack4')) {
|
|
40
|
+
// taro webpack4 中, 未正确识别到 axios package.json 中的 browser 字段, 以致于打包进入了 node 相关的代码(https://github.com/axios/axios/blob/59eb99183546d822bc27e881f5dcd748daa04173/package.json#L128-L132)
|
|
41
|
+
const inAxiosReg = /(\/|\\)(node_modules)(\/|\\)(axios)(\/|\\)/
|
|
42
|
+
chain.merge({
|
|
43
|
+
externals: [
|
|
44
|
+
(context, request, callback) => {
|
|
45
|
+
if (inAxiosReg.test(context) && request.includes('http.js')) {
|
|
46
|
+
// 将 http 适配器从源码里干掉 https://github.com/axios/axios/blob/59eb99183546d822bc27e881f5dcd748daa04173/lib/adapters/adapters.js#L2
|
|
47
|
+
return callback(null, 'var undefined')
|
|
48
|
+
}
|
|
49
|
+
callback()
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
})
|
|
53
|
+
}
|
|
38
54
|
}
|
|
39
55
|
})
|
|
40
56
|
|