vitejs / vite

Next generation frontend tooling. It's fast!
http://vite.dev
MIT License
69.03k stars 6.24k forks source link

when import dva append a problem #9288

Closed mcfly001 closed 2 years ago

mcfly001 commented 2 years ago

Describe the bug

When I project reference dva, Vite error, because warnAboutDeprecatedCJSRequire.js

import React from 'react';
import { Button, message } from 'antd';
import dva from 'dva';
import { Router, Route, Switch, Redirect } from 'dva/router';
import { createHistory } from '@/utils/history';
import './App.css';

const app = dva({
    history: createHistory(),
    onError(e) {
        message.error(e.message, 3);
    }
});
module.exports = function (member) {
    printWarning(
        'Please use `require("history").%s` instead of `require("history/%s")`. ' +
        'Support for the latter will be removed in the next major release.',
        [member, member]
    );
};

image

vite: 3.0.2 dva: 2.4.1

Reproduction

cra import dva

System Info

System:
    OS: macOS 11.2.3
    CPU: (4) x64 Intel(R) Core(TM) i5-5350U CPU @ 1.80GHz
    Memory: 21.14 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.15.0 - ~/.nvm/versions/node/v16.15.0/bin/node
    Yarn: 1.22.18 - ~/node_modules/.bin/yarn
    npm: 8.5.5 - ~/.nvm/versions/node/v16.15.0/bin/npm
  Browsers:
    Chrome: 103.0.5060.134
    Safari: 14.0.3

Used Package Manager

npm

Logs

No response

Validations

mcfly001 commented 2 years ago

when i remove link this, vite is ok image

sapphi-red commented 2 years ago

Please create a reproduction with git repository or stackblitz.

github-actions[bot] commented 2 years ago

Hello @mcfly001. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with need reproduction will be closed if they have no activity within 3 days.