@tarojs/plugin-react-devtools 3.6.2-canary.1 → 3.6.2-canary.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/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { chalk, fs } from '@tarojs/helper'\nimport { isArray, isString } from '@tarojs/shared'\n\nimport type { IPluginContext, TaroPlatformBase } from '@tarojs/service'\n\nconst spawn = require('cross-spawn')\nconst detectPort = require('detect-port')\n\
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { chalk, fs } from '@tarojs/helper'\nimport { isArray, isString } from '@tarojs/shared'\n\nimport type { IPluginContext, TaroPlatformBase } from '@tarojs/service'\n\nconst spawn = require('cross-spawn')\nconst detectPort = require('detect-port')\n\nexport interface IOptions {\n enabled?: boolean\n hostname?: string\n port?: string\n}\n\nexport default function (ctx: IPluginContext, options: IOptions) {\n if (process.env.NODE_ENV === 'production' || options.enabled === false) return\n\n const hostname = JSON.stringify(options.hostname || 'localhost')\n const port = Number(options.port || '8097')\n\n detectPort(port, (err, availablePort) => {\n if (err) {\n // eslint-disable-next-line no-console\n console.log(`detectPort 错误:${err}`)\n }\n\n if (availablePort === port) {\n // eslint-disable-next-line no-console\n console.log(chalk.yellow('\\n提示 ') + '正在启动 react-devtools...\\n')\n spawn(require.resolve('react-devtools/bin'), { env: { ...process.env, PORT: port } })\n }\n })\n\n ctx.registerMethod({\n name: 'onSetupClose',\n fn (platform: TaroPlatformBase) {\n injectRuntimePath(platform)\n }\n })\n\n ctx.modifyWebpackChain(({ chain }) => {\n chain\n .plugin('definePlugin')\n .tap(args => {\n const config = args[0]\n config.__REACT_DEVTOOLS_HOSTNAME__ = hostname\n config.__REACT_DEVTOOLS_PORT__ = port\n return args\n })\n\n // 最理想是可以使用 definePlugin 设置 __REACT_DEVTOOLS_GLOBAL_HOOK__: window.__REACT_DEVTOOLS_GLOBAL_HOOK__\n // 但是 providerPlugin 不会识别 definePlugin 改写的 window 从而注入 window,可能是两个插件的调用时机问题\n // 因此使用 loader 魔改 react-reconciler,代替 definePlugin\n chain.merge({\n module: {\n rule: {\n 'plugin-react-devtools': {\n test: /react-reconciler\\.(production|development)/,\n loader: require.resolve('./loader')\n }\n }\n }\n })\n })\n\n ctx.modifyRunnerOpts(({ opts }) => {\n if (!opts?.compiler) return\n\n if (isString(opts.compiler)) {\n opts.compiler = {\n type: opts.compiler\n }\n }\n if (opts.compiler.type === 'webpack5') {\n opts.compiler.prebundle ||= {}\n const prebundle = opts.compiler.prebundle\n if (prebundle.enable === false) return\n\n // 代替 ./loader 里的功能\n const taroReactDevtoolsPlugin = {\n name: 'taroReactDevtoolsPlugin',\n setup (build) {\n build.onLoad({ filter: /react-reconciler\\.(production|development)/ }, ({ path }) => {\n const content = fs.readFileSync(path).toString()\n return {\n contents: content.replace(/__REACT_DEVTOOLS_GLOBAL_HOOK__/g, 'window.__REACT_DEVTOOLS_GLOBAL_HOOK__')\n }\n })\n }\n }\n\n prebundle.esbuild ||= {}\n const esbuildConfig = prebundle.esbuild\n esbuildConfig.plugins ||= []\n esbuildConfig.plugins.push(taroReactDevtoolsPlugin)\n }\n })\n}\n\nfunction injectRuntimePath (platform: TaroPlatformBase) {\n const injectedPath = 'post:@tarojs/plugin-react-devtools/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"],"names":["chalk","isString","fs","isArray"],"mappings":";;;;;;;AAKA,MAAM,KAAK,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;AACpC,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;AAQhB,cAAA,EAAA,GAAmB,EAAE,OAAiB,EAAA;AAC7D,IAA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wBAClF,MAAM,OAAO,GAAGC,SAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAA;wBAChD,OAAO;4BACL,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,iCAAiC,EAAE,uCAAuC,CAAC;yBACtG,CAAA;AACH,qBAAC,CAAC,CAAA;iBACH;aACF,CAAA;YAED,SAAS,CAAC,OAAO,KAAjB,SAAS,CAAC,OAAO,GAAK,EAAE,CAAA,CAAA;AACxB,YAAA,MAAM,aAAa,GAAG,SAAS,CAAC,OAAO,CAAA;YACvC,aAAa,CAAC,OAAO,KAArB,aAAa,CAAC,OAAO,GAAK,EAAE,CAAA,CAAA;AAC5B,YAAA,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAA;AACpD,SAAA;AACH,KAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAE,QAA0B,EAAA;IACpD,MAAM,YAAY,GAAG,iDAAiD,CAAA;AACtE,IAAA,IAAIC,cAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;AACjC,QAAA,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;AACxC,KAAA;AAAM,SAAA,IAAIF,eAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;QACzC,QAAQ,CAAC,WAAW,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,YAAY,CAAC,CAAA;AAC5D,KAAA;AACH;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/plugin-react-devtools",
|
|
3
|
-
"version": "3.6.2-canary.
|
|
3
|
+
"version": "3.6.2-canary.2",
|
|
4
4
|
"description": "Taro 小程序端支持使用 React DevTools 的插件",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -25,15 +25,15 @@
|
|
|
25
25
|
"cross-spawn": "^7.0.3",
|
|
26
26
|
"detect-port": "^1.3.0",
|
|
27
27
|
"react-devtools": "4.14.0",
|
|
28
|
-
"@tarojs/helper": "3.6.2-canary.
|
|
29
|
-
"@tarojs/service": "3.6.2-canary.
|
|
30
|
-
"@tarojs/shared": "3.6.2-canary.
|
|
31
|
-
"@tarojs/taro": "3.6.2-canary.
|
|
28
|
+
"@tarojs/helper": "3.6.2-canary.2",
|
|
29
|
+
"@tarojs/service": "3.6.2-canary.2",
|
|
30
|
+
"@tarojs/shared": "3.6.2-canary.2",
|
|
31
|
+
"@tarojs/taro": "3.6.2-canary.2"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"rollup": "^3.8.1",
|
|
35
35
|
"rollup-plugin-copy": "^3.4.0",
|
|
36
|
-
"rollup-plugin-node-externals": "^
|
|
36
|
+
"rollup-plugin-node-externals": "^5.0.0",
|
|
37
37
|
"rollup-plugin-ts": "^3.0.2",
|
|
38
38
|
"typescript": "^4.7.4"
|
|
39
39
|
},
|