{"id":26460,"library":"taro-plugin-compiler-optimization","title":"Taro Compiler Optimization Plugin","description":"A Taro plugin that accelerates compilation and bundling speed using multi-core processing and caching. Current version 1.0.4. It leverages thread-loader for parallelizing tasks and cache-loader for caching SCSS compilation results, reducing build time from minutes to under a minute for large projects. Only supports Taro 3, React, and SCSS; does not support Vue or H5 builds due to thread-loader limitations. It is an essential performance tool for Taro React projects.","status":"active","version":"1.0.4","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","taro","taro-plugin"],"install":[{"cmd":"npm install taro-plugin-compiler-optimization","lang":"bash","label":"npm"},{"cmd":"yarn add taro-plugin-compiler-optimization","lang":"bash","label":"yarn"},{"cmd":"pnpm add taro-plugin-compiler-optimization","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"required for multi-core parallel compilation","package":"thread-loader","optional":false},{"reason":"required for caching SCSS compilation results","package":"cache-loader","optional":false}],"imports":[{"note":"Must be an array with the plugin name and options object, not just a string. Inserted in Taro's config/index.js plugins array.","wrong":"plugins: ['taro-plugin-compiler-optimization']","symbol":"plugin","correct":"plugins: [['taro-plugin-compiler-optimization', { closeScssCache: false }]]"},{"note":"CommonJS require is the correct usage in Taro config files; ESM import may not work. Plugin is used by string name, not imported directly.","wrong":"import CompilerOptimizationPlugin from 'taro-plugin-compiler-optimization'","symbol":"default","correct":"const CompilerOptimizationPlugin = require('taro-plugin-compiler-optimization')"},{"note":"The options object is optional; closeScssCache defaults to false if omitted.","wrong":"type PluginOptions = { closeScssCache: boolean }","symbol":"options type","correct":"type PluginOptions = { closeScssCache?: boolean }"}],"quickstart":{"code":"npm install --save-dev thread-loader cache-loader taro-plugin-compiler-optimization\n\n// config/index.js\nmodule.exports = {\n  // ...\n  plugins: [\n    ['taro-plugin-compiler-optimization', {\n      closeScssCache: false\n    }]\n  ]\n}","lang":"javascript","description":"Install required loaders and plugin, then add to Taro config's plugins array with options object."},"warnings":[{"fix":"Ensure project uses Taro 3 and React. Use only in React projects; Vue not supported.","message":"Only supports Taro 3 and React techn stack.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Use SCSS for styling; other CSS preprocessors (Less, Sass) are not cached.","message":"CSS caching only works with SCSS syntax.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Only use this plugin with React native/mini-program builds. For H5, do not include this plugin.","message":"Does not support Vue framework or H5 builds due to thread-loader limitations.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Use ['taro-plugin-compiler-optimization', { closeScssCache: false }] instead of just the string.","message":"Options object must be provided even if empty; otherwise error.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Place this plugin after other plugins if possible, or at the start. No strict requirement documented.","message":"Plugin order in plugins array may affect performance.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run npm install --save-dev thread-loader","cause":"thread-loader not installed as devDependency","error":"Cannot find module 'thread-loader'"},{"fix":"Run npm install --save-dev cache-loader","cause":"cache-loader not installed as devDependency","error":"Cannot find module 'cache-loader'"},{"fix":"Ensure the package is installed and the plugins entry is an array with a string name and options object.","cause":"Plugin not installed or misconfigured in plugins array","error":"TypeError: Plugin is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}