How to use the @dcloudio/uni-cli-shared.hasModule function in @dcloudio/uni-cli-shared

To help you get started, we’ve selected a few @dcloudio/uni-cli-shared examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dcloudio / uni-app / packages / vue-cli-plugin-uni / lib / configure-webpack.js View on Github external
function removeForkTsCheckerWebpackPlugin (rawPlugins) {
    if (isInHBuilderX && hasModule('fork-ts-checker-webpack-plugin')) {
      const pluginIndex = rawPlugins.findIndex(rawPlugin => rawPlugin.vue && rawPlugin.typescriptVersion)
      if (pluginIndex !== -1) { // 移除fork-ts-checker-webpack-plugin
        rawPlugins.splice(pluginIndex, 1)
      }
    }
  }
github dcloudio / uni-app / packages / vue-cli-plugin-hbuilderx / module-alias.js View on Github external
}
  return request
})
if (isInHBuilderX) {
  moduleAlias.addAlias('typescript', path.resolve(process.env.UNI_HBUILDERX_PLUGINS,
    'compile-typescript/node_modules/typescript'))
  moduleAlias.addAlias('less', path.resolve(process.env.UNI_HBUILDERX_PLUGINS,
    'compile-less/node_modules/less'))
  moduleAlias.addAlias('node-sass', path.resolve(process.env.UNI_HBUILDERX_PLUGINS,
    'compile-node-sass/node_modules/node-sass-china'))
  moduleAlias.addAlias('stylus', path.resolve(process.env.UNI_HBUILDERX_PLUGINS,
    'compile-stylus/node_modules/stylus'))
  moduleAlias.addAlias('pug', path.resolve(process.env.UNI_HBUILDERX_PLUGINS,
    'compile-pug-cli/node_modules/pug'))

  if (!hasModule('typescript')) { // 因为 cli-plugin-typescript 会直接读取typescript/package.json,故,如果未安装 typescript,则先设置一个假的
    moduleAlias.addAlias('typescript/package.json', path.resolve(__dirname, 'typescript.json'))
    moduleAlias.addAlias('fork-ts-checker-webpack-plugin', path.resolve(__dirname,
      'fork-ts-checker-webpack-plugin.fake.js'))
  }
}