vbenjs / vite-plugin-mock

A mock plugin for vite.use mockjs.
MIT License
621 stars 96 forks source link

warning: "esbuild" should be marked as external for use with "require.resolve #65

Open llyp618 opened 2 years ago

llyp618 commented 2 years ago

Vite: 2.7.13

vite-plugin-mock: 2.9.6

vite.config:

defineConfig({
  plugins: [
    vue(),
    vueJsx(),
    viteMockServe({
      mockPath: 'mock',
      localEnabled: true,
      prodEnabled: false,
      supportTs: true,
      watchFiles: true,
    }),
  ],
});

Error

node_modules/vite/dist/node/chunks/dep-1412e872.js:2501:6: warning: Indirect calls to "require" will not be bundled (surround with a try/catch to silence this warning)
    2501 │     : require;
         ╵       ~~~~~~~

 > node_modules/vite/dist/node/chunks/dep-1412e872.js:22674:15: warning: This call to "require" will not be bundled because the argument is not a string literal (surround with a try/catch to silence this warning)
    22674 │         return require(terserPath).minify(code, options);
          ╵                ~~~~~~~

 > node_modules/vite/dist/node/chunks/dep-1412e872.js:71402:16: warning: This call to "require" will not be bundled because the argument is not a string literal (surround with a try/catch to silence this warning)
    71402 │     const raw = require(fileName);
          ╵                 ~~~~~~~

 > node_modules/vite/dist/node/chunks/dep-1412e872.js:1187:37: warning: "vite/dist/client/client.mjs" should be marked as external for use with "require.resolve"
    1187 │ const CLIENT_ENTRY = require.resolve('vite/dist/client/client.mjs');
         ╵                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 > node_modules/vite/dist/node/chunks/dep-1412e872.js:1189:34: warning: "vite/dist/client/env.mjs" should be marked as external for use with "require.resolve"
    1189 │ const ENV_ENTRY = require.resolve('vite/dist/client/env.mjs');

Did i miss any information ?

paobai commented 2 years ago

mark

paobai commented 2 years ago

please tell me if you find a solution

paobai commented 2 years ago

my faults 。in mock files change import { MockMethod } from "vite-plugin-mock" to import type { MockMethod } from "vite-plugin-mock"