Git Product home page Git Product logo

umi-webpack5-export's Introduction

umi-webpack5-export

有些插件和loader引入了webpack的模块(比如monaco-editor-webpack-plugin、worker-loader),
会有The 'compilation' argument must be an instance of Compilation错误。
这个错误是由存在多个webpack引起的。

这个库导出[email protected] webpack5模式下@umijs/deps的webpack模块,重定向到webpack模块。
用于解决使用webpack插件引起的多个webpack冲突的问题。

使用

安装时覆盖webpack。

{
  "devDependencies": {
    "webpack": "npm:@bbkkbkk/umi-webpack5-export"
  }
}

或者使用module-alias,在config.js文件头部加载如下alias.js文件。

// alias.js
import moduleAlias from 'module-alias';

moduleAlias.addAlias('webpack', function(fromPath, request, alias) {
  if (/@umijs[\\/]/.test(fromPath)) {
    return 'webpack';
  }

  // umi的某个版本在使用worker-loader时会提示错误,添加如下代码
  // 没有错误的话不要加这个
  if (/worker-loader/.test(fromPath)) {
    if (/ExternalsPlugin|FetchCompileWasmPlugin|FetchCompileAsyncWasmPlugin/i.test(request)) {
      return '@bbkkbkk/umi-webpack5-export';
    }

    return 'webpack';
  }

  return '@bbkkbkk/umi-webpack5-export';
});

导入webpack。

import webpack from 'webpack';
// or
const webpack = require('webpack');

导入@umi/deps的bundle。

import { bundle } from '@bbkkbkk/umi-webpack5-export/bundle';

编译

  • npm run build 编译文件
  • npm run test 测试

umi-webpack5-export's People

Contributors

duan602728596 avatar

Watchers

James Cloos avatar  avatar

Forkers

liruiqing

umi-webpack5-export's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.