ReferenceError: APP_A is not defined
at Object. (E:\testwork\tapp367\src\app.config.ts:26:13)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at requireFromString (E:\testwork\tapp367\node_modules\require-from-string\index.js:28:4)
at requireWithEsbuild (E:\testwork\tapp367\node_modules\@tarojs\helper\src\esbuild\index.ts:50:27)
at readConfig (E:\testwork\tapp367\node_modules\@tarojs\helper\src\utils.ts:604:34)
at MiniPrebundle.getEntries (E:\testwork\tapp367\node_modules\@tarojs\webpack5-prebundle\src\prebundle\index.ts:137:35)
at MiniPrebundle. (E:\testwork\tapp367\node_modules\@tarojs\webpack5-prebundle\src\mini.ts:224:36)
at Generator.next ()
at E:\testwork\tapp367\node_modules\@tarojs\webpack5-prebundle\dist\mini.js:8:71
at new Promise ()
依赖预编译失败,已经为您跳过预编译步骤,但是编译速度可能会受到影响。
(node:22596) UnhandledPromiseRejectionWarning: ReferenceError: APP_A is not defined
at Object. (E:\testwork\tapp367\src\app.config.ts:26:13)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at requireFromString (E:\testwork\tapp367\node_modules\require-from-string\index.js:28:4)
at requireWithEsbuild (E:\testwork\tapp367\node_modules\@tarojs\helper\src\esbuild\index.ts:50:27)
at readConfig (E:\testwork\tapp367\node_modules\@tarojs\helper\src\utils.ts:604:34)
at MiniSplitChunksPlugin.getSubpackageConfig (E:\testwork\tapp367\node_modules\@tarojs\webpack5-runner\src\plugins\MiniSplitChunksPlugin.ts:593:44)
at MiniSplitChunksPlugin.apply (E:\testwork\tapp367\node_modules\@tarojs\webpack5-runner\src\plugins\MiniSplitChunksPlugin.ts:330:29)
at createCompiler (E:\testwork\tapp367\node_modules\webpack\lib\webpack.js:73:12)
at create (E:\testwork\tapp367\node_modules\webpack\lib\webpack.js:134:16)
at webpack (E:\testwork\tapp367\node_modules\webpack\lib\webpack.js:158:32)
(Use node --trace-warnings ... to show where the warning was created)
(node:22596) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
(node:22596) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
相关平台
微信小程序
复现仓库
git@github.com:zhgh/taro-defineConstants.git 小程序基础库: 2 使用框架: React
复现步骤
npx @tarojs/cli@3.6.7 init tApp 直接使用最新模板,然后增加自定义变量,增加全局ts声明。编译失败
期望结果
可以正常读取全局变量
实际结果
ReferenceError: APP_A is not defined at Object. (E:\testwork\tapp367\src\app.config.ts:26:13)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at requireFromString (E:\testwork\tapp367\node_modules\require-from-string\index.js:28:4)
at requireWithEsbuild (E:\testwork\tapp367\node_modules\@tarojs\helper\src\esbuild\index.ts:50:27)
at readConfig (E:\testwork\tapp367\node_modules\@tarojs\helper\src\utils.ts:604:34)
at MiniPrebundle.getEntries (E:\testwork\tapp367\node_modules\@tarojs\webpack5-prebundle\src\prebundle\index.ts:137:35)
at MiniPrebundle. (E:\testwork\tapp367\node_modules\@tarojs\webpack5-prebundle\src\mini.ts:224:36)
at Generator.next ()
at E:\testwork\tapp367\node_modules\@tarojs\webpack5-prebundle\dist\mini.js:8:71
at new Promise ()
依赖预编译失败,已经为您跳过预编译步骤,但是编译速度可能会受到影响。
(node:22596) UnhandledPromiseRejectionWarning: ReferenceError: APP_A is not defined
at Object. (E:\testwork\tapp367\src\app.config.ts:26:13)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at requireFromString (E:\testwork\tapp367\node_modules\require-from-string\index.js:28:4)
at requireWithEsbuild (E:\testwork\tapp367\node_modules\@tarojs\helper\src\esbuild\index.ts:50:27)
at readConfig (E:\testwork\tapp367\node_modules\@tarojs\helper\src\utils.ts:604:34)
at MiniSplitChunksPlugin.getSubpackageConfig (E:\testwork\tapp367\node_modules\@tarojs\webpack5-runner\src\plugins\MiniSplitChunksPlugin.ts:593:44)
at MiniSplitChunksPlugin.apply (E:\testwork\tapp367\node_modules\@tarojs\webpack5-runner\src\plugins\MiniSplitChunksPlugin.ts:330:29)
at createCompiler (E:\testwork\tapp367\node_modules\webpack\lib\webpack.js:73:12)
at create (E:\testwork\tapp367\node_modules\webpack\lib\webpack.js:134:16)
at webpack (E:\testwork\tapp367\node_modules\webpack\lib\webpack.js:158:32)
(Use
node --trace-warnings ...
to show where the warning was created) (node:22596) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3) (node:22596) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.环境信息