How to use the @vue/cli-shared-utils.resolveModule function in @vue/cli-shared-utils

To help you get started, we’ve selected a few @vue/cli-shared-utils 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 vuejs / vue-cli / packages / @vue / cli-plugin-eslint / index.js View on Github external
.exclude
            .add(/node_modules/)
            .add(path.dirname(require.resolve('@vue/cli-service')))
            .end()
          .test(/\.(vue|(j|t)sx?)$/)
          .use('eslint-loader')
            .loader(require.resolve('eslint-loader'))
            .options({
              extensions,
              cache: true,
              cacheIdentifier,
              emitWarning: allWarnings,
              // only emit errors in production mode.
              emitError: allErrors,
              eslintPath: path.dirname(
                resolveModule('eslint/package.json', cwd) ||
                resolveModule('eslint/package.json', __dirname)
              ),
              formatter: loadModule('eslint/lib/formatters/codeframe', cwd, true)
            })
    })
  }
github vuejs / vue-cli / packages / @vue / cli-plugin-eslint / index.js View on Github external
.add(/node_modules/)
            .add(path.dirname(require.resolve('@vue/cli-service')))
            .end()
          .test(/\.(vue|(j|t)sx?)$/)
          .use('eslint-loader')
            .loader(require.resolve('eslint-loader'))
            .options({
              extensions,
              cache: true,
              cacheIdentifier,
              emitWarning: allWarnings,
              // only emit errors in production mode.
              emitError: allErrors,
              eslintPath: path.dirname(
                resolveModule('eslint/package.json', cwd) ||
                resolveModule('eslint/package.json', __dirname)
              ),
              formatter: loadModule('eslint/lib/formatters/codeframe', cwd, true)
            })
    })
  }
github vuejs / vue-cli / packages / @vue / cli-ui / apollo-server / connectors / plugins.js View on Github external
return progress.wrap(PROGRESS_ID, context, async setProgress => {
    setProgress({
      status: 'plugin-invoke',
      args: [id]
    })

    clearModule('@vue/cli-service/webpack.config.js', cwd.get())

    currentPluginId = id
    // Allow plugins that don't have a generator
    if (resolveModule(`${id}/generator`, cwd.get())) {
      const child = execa('vue', [
        'invoke',
        id,
        '--$inlineOptions',
        JSON.stringify(prompts.getAnswers())
      ], {
        cwd: cwd.get(),
        stdio: ['inherit', 'pipe', 'inherit']
      })

      const onData = buffer => {
        const text = buffer.toString().trim()
        if (text) {
          setProgress({
            info: text
          })
github athm-fe / create-autofe-app / packages / autofe-scripts / config / webpack.config.js View on Github external
rules: [
        // eslint
        {
          enforce: 'pre',
          test: /\.js$/,
          include: config.appSrc,
          use: [
            {
              loader: require.resolve('eslint-loader'),
              options: {
                // TODO: cache 需要 cacheIdentifier,参考 vue-cli
                // cache: true,
                emitWarning: true,
                emitError: false,
                eslintPath: path.dirname(
                  resolveModule('eslint/package.json', context) ||
                  resolveModule('eslint/package.json', __dirname)
                ),
              },
            },
          ],
        },
        // js
        {
          test: /\.js$/,
          exclude: (filepath) => {
            // Notice: 处理 @babel/runtime 会导致很多没必要的 Polyfills,暂时去掉
            // only include @babel/runtime when the babel-preset-autofe-app preset is used
            // if (
            //   process.env.CREATOR_TRANSPILE_BABEL_RUNTIME &&
            //   filepath.includes(path.join('@babel', 'runtime'))
            // ) {
github KuangPF / vue-cli-analysis / packages / @vue / cli / lib / add.js View on Github external
// @bar/foo => @bar/vue-cli-plugin-foo
  // @vue/foo => @vue/cli-plugin-foo
  // foo => vue-cli-plugin-foo
  const packageName = resolvePluginId(pluginName)

  log()
  log(`📦  Installing ${chalk.cyan(packageName)}...`)
  log()

  const packageManager = loadOptions().packageManager || (hasProjectYarn(context) ? 'yarn' : 'npm')
  await installPackage(context, packageManager, options.registry, packageName)

  log(`${chalk.green('✔')}  Successfully installed plugin: ${chalk.cyan(packageName)}`)
  log()

  const generatorPath = resolveModule(`${packageName}/generator`, context)
  if (generatorPath) {
    invoke(pluginName, options, context)
  } else {
    log(`Plugin ${packageName} does not have a generator to invoke`)
  }
}
github athm-fe / create-autofe-app / packages / autofe-scripts / config / webpack.config.js View on Github external
// eslint
        {
          enforce: 'pre',
          test: /\.js$/,
          include: config.appSrc,
          use: [
            {
              loader: require.resolve('eslint-loader'),
              options: {
                // TODO: cache 需要 cacheIdentifier,参考 vue-cli
                // cache: true,
                emitWarning: true,
                emitError: false,
                eslintPath: path.dirname(
                  resolveModule('eslint/package.json', context) ||
                  resolveModule('eslint/package.json', __dirname)
                ),
              },
            },
          ],
        },
        // js
        {
          test: /\.js$/,
          exclude: (filepath) => {
            // Notice: 处理 @babel/runtime 会导致很多没必要的 Polyfills,暂时去掉
            // only include @babel/runtime when the babel-preset-autofe-app preset is used
            // if (
            //   process.env.CREATOR_TRANSPILE_BABEL_RUNTIME &&
            //   filepath.includes(path.join('@babel', 'runtime'))
            // ) {
            //   return false;
github KuangPF / vue-cli-analysis / packages / @vue / cli-ui / apollo-server / connectors / plugins.js View on Github external
return progress.wrap(PROGRESS_ID, context, async setProgress => {
    setProgress({
      status: 'plugin-invoke',
      args: [id]
    })

    clearModule('@vue/cli-service/webpack.config.js', cwd.get())

    currentPluginId = id
    // Allow plugins that don't have a generator
    if (resolveModule(`${id}/generator`, cwd.get())) {
      await invoke(id, prompts.getAnswers(), cwd.get())
    }
    // Run plugin api
    runPluginApi(id, getApi(cwd.get()), context)
    installationStep = 'diff'

    notify({
      title: `Plugin invoked successfully`,
      message: `Plugin ${id} invoked successfully`,
      icon: 'done'
    })

    return getInstallation(context)
  })
}
github vuejs / vue-cli / packages / @vue / cli / lib / add.js View on Github external
log(`📦  Installing ${chalk.cyan(packageName)}...`)
  log()

  const pm = new PackageManager({ context })

  const cliVersion = require('../package.json').version
  if (isOfficialPlugin(packageName) && semver.prerelease(cliVersion)) {
    await pm.add(`${packageName}@^${cliVersion}`)
  } else {
    await pm.add(packageName)
  }

  log(`${chalk.green('✔')}  Successfully installed plugin: ${chalk.cyan(packageName)}`)
  log()

  const generatorPath = resolveModule(`${packageName}/generator`, context)
  if (generatorPath) {
    invoke(pluginName, options, context)
  } else {
    log(`Plugin ${packageName} does not have a generator to invoke`)
  }
}