aackerman / circular-dependency-plugin

Detect circular dependencies in modules compiled with Webpack
https://www.npmjs.com/package/circular-dependency-plugin
ISC License
921 stars 47 forks source link

webpack@5 support #60

Closed kubijo closed 4 years ago

kubijo commented 4 years ago

Hi. Thanks for your work on this. What I come with is a question that sooner or later surely would come anyway and that is whether you are planing a webpack@5 checkup.

I'm now helping with polishing out kinks in it and of issues that came up in my project are many new circular dependency errors — some of which don't make any sense like one file depend on itself.

aackerman commented 4 years ago

Can you post the version of webpack and plugins you're using from your lockfile?

jlchereau commented 4 years ago
ERROR in Circular dependency detected:
src\styles\themes\app.theme.bootstrap.scss -> src\styles\themes\app.theme.bootstrap.scss

Did not occur with webpack 4.44.2 -> now occurs with webpack 5.0.0

    "css-loader": "^4.3.0",
    "file-loader": "^6.1.1",
    "sass": "^1.27.0",
    "sass-loader": "^10.0.3",
    "style-loader": "^2.0.0",
    "url-loader": "^4.1.1",
    "webpack": "^5.0.0",
    "webpack-cli": "^4.0.0",
kubijo commented 4 years ago

Sorry, I'm doing several things at once and @jlchereau was faster, but it's a relevant ... both webpack and the set of plugins. I think the new webpack is the most relevant part

aackerman commented 4 years ago

@jlchereau those appear to be the versions from your package.json, I would like to see the exact version from package-lock.json or yarn.lock. A lot of people use this module with Webpack 5 so if the issue is with a specific or very recent version I would like to know.

jlchereau commented 4 years ago

This concerns the final release of webpack@5 dated 2 days ago: https://github.com/webpack/webpack/releases/tag/v5.0.0. I have never tried any of the release candidates.

    "webpack": {
      "version": "5.0.0",
      "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.0.0.tgz",
      "integrity": "sha512-OK+Q9xGgda3idw/DgCf75XsVFxRLPu48qPwygqI3W9ls5sDdKif5Ay4SM/1UVob0w4juJy14Zv9nNv0WeyV0aA==",
      "dev": true,
      "requires": {
        "@types/eslint-scope": "^3.7.0",
        "@types/estree": "^0.0.45",
        "@webassemblyjs/ast": "1.9.0",
        "@webassemblyjs/helper-module-context": "1.9.0",
        "@webassemblyjs/wasm-edit": "1.9.0",
        "@webassemblyjs/wasm-parser": "1.9.0",
        "acorn": "^8.0.3",
        "browserslist": "^4.14.3",
        "chrome-trace-event": "^1.0.2",
        "enhanced-resolve": "^5.2.0",
        "eslint-scope": "^5.1.0",
        "events": "^3.2.0",
        "glob-to-regexp": "^0.4.1",
        "graceful-fs": "^4.2.4",
        "json-parse-better-errors": "^1.0.2",
        "loader-runner": "^4.1.0",
        "mime-types": "^2.1.27",
        "neo-async": "^2.6.2",
        "pkg-dir": "^4.2.0",
        "schema-utils": "^3.0.0",
        "tapable": "^2.0.0",
        "terser-webpack-plugin": "^4.1.0",
        "watchpack": "^2.0.0",
        "webpack-sources": "^2.0.1"
      },
      "dependencies": {
        "@types/estree": {
          "version": "0.0.45",
          "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.45.tgz",
          "integrity": "sha512-jnqIUKDUqJbDIUxm0Uj7bnlMnRm1T/eZ9N+AVMqhPgzrba2GhGG5o/jCTwmdPK709nEZsGoMzXEDUjcXHa3W0g==",
          "dev": true
        },
        "acorn": {
          "version": "8.0.4",
          "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.0.4.tgz",
          "integrity": "sha512-XNP0PqF1XD19ZlLKvB7cMmnZswW4C/03pRHgirB30uSJTaS3A3V1/P4sS3HPvFmjoriPCJQs+JDSbm4bL1TxGQ==",
          "dev": true
        },
        "browserslist": {
          "version": "4.14.5",
          "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.14.5.tgz",
          "integrity": "sha512-Z+vsCZIvCBvqLoYkBFTwEYH3v5MCQbsAjp50ERycpOjnPmolg1Gjy4+KaWWpm8QOJt9GHkhdqAl14NpCX73CWA==",
          "dev": true,
          "requires": {
            "caniuse-lite": "^1.0.30001135",
            "electron-to-chromium": "^1.3.571",
            "escalade": "^3.1.0",
            "node-releases": "^1.1.61"
          }
        },
        "caniuse-lite": {
          "version": "1.0.30001148",
          "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001148.tgz",
          "integrity": "sha512-E66qcd0KMKZHNJQt9hiLZGE3J4zuTqE1OnU53miEVtylFbwOEmeA5OsRu90noZful+XGSQOni1aT2tiqu/9yYw==",
          "dev": true
        },
        "electron-to-chromium": {
          "version": "1.3.578",
          "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.578.tgz",
          "integrity": "sha512-z4gU6dA1CbBJsAErW5swTGAaU2TBzc2mPAonJb00zqW1rOraDo2zfBMDRvaz9cVic+0JEZiYbHWPw/fTaZlG2Q==",
          "dev": true
        },
        "enhanced-resolve": {
          "version": "5.2.0",
          "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.2.0.tgz",
          "integrity": "sha512-NZlGLl8DxmZoq0uqPPtJfsCAir68uR047+Udsh1FH4+5ydGQdMurn/A430A1BtxASVmMEuS7/XiJ5OxJ9apAzQ==",
          "dev": true,
          "requires": {
            "graceful-fs": "^4.2.4",
            "tapable": "^2.0.0"
          }
        },
        "escalade": {
          "version": "3.1.0",
          "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.0.tgz",
          "integrity": "sha512-mAk+hPSO8fLDkhV7V0dXazH5pDc6MrjBTPyD3VeKzxnVFjH1MIxbCdqGZB9O8+EwWakZs3ZCbDS4IpRt79V1ig==",
          "dev": true
        },
        "events": {
          "version": "3.2.0",
          "resolved": "https://registry.npmjs.org/events/-/events-3.2.0.tgz",
          "integrity": "sha512-/46HWwbfCX2xTawVfkKLGxMifJYQBWMwY1mjywRtb4c9x8l5NP3KoJtnIOiL1hfdRkIuYhETxQlo62IF8tcnlg==",
          "dev": true
        },
        "find-up": {
          "version": "4.1.0",
          "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
          "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
          "dev": true,
          "requires": {
            "locate-path": "^5.0.0",
            "path-exists": "^4.0.0"
          }
        },
        "graceful-fs": {
          "version": "4.2.4",
          "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz",
          "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==",
          "dev": true
        },
        "locate-path": {
          "version": "5.0.0",
          "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
          "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
          "dev": true,
          "requires": {
            "p-locate": "^4.1.0"
          }
        },
        "mime-db": {
          "version": "1.44.0",
          "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz",
          "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==",
          "dev": true
        },
        "mime-types": {
          "version": "2.1.27",
          "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz",
          "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==",
          "dev": true,
          "requires": {
            "mime-db": "1.44.0"
          }
        },
        "node-releases": {
          "version": "1.1.61",
          "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.61.tgz",
          "integrity": "sha512-DD5vebQLg8jLCOzwupn954fbIiZht05DAZs0k2u8NStSe6h9XdsuIQL8hSRKYiU8WUQRznmSDrKGbv3ObOmC7g==",
          "dev": true
        },
        "p-locate": {
          "version": "4.1.0",
          "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
          "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
          "dev": true,
          "requires": {
            "p-limit": "^2.2.0"
          }
        },
        "path-exists": {
          "version": "4.0.0",
          "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
          "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
          "dev": true
        },
        "pkg-dir": {
          "version": "4.2.0",
          "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz",
          "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==",
          "dev": true,
          "requires": {
            "find-up": "^4.0.0"
          }
        },
        "source-map": {
          "version": "0.6.1",
          "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
          "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
          "dev": true
        },
        "tapable": {
          "version": "2.0.0",
          "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.0.0.tgz",
          "integrity": "sha512-bjzn0C0RWoffnNdTzNi7rNDhs1Zlwk2tRXgk8EiHKAOX1Mag3d6T0Y5zNa7l9CJ+EoUne/0UHdwS8tMbkh9zDg==",
          "dev": true
        },
        "webpack-sources": {
          "version": "2.0.1",
          "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-2.0.1.tgz",
          "integrity": "sha512-A9oYz7ANQBK5EN19rUXbvNgfdfZf5U2gP0769OXsj9CvYkCR6OHOsd6OKyEy4H38GGxpsQPKIL83NC64QY6Xmw==",
          "dev": true,
          "requires": {
            "source-list-map": "^2.0.1",
            "source-map": "^0.6.1"
          }
        }
      }
    },
aackerman commented 4 years ago

My tests with the final webpack v5 are coming out the same in this PR https://github.com/aackerman/circular-dependency-plugin/pull/61.

@kubijo did you originally see issues with JS only imports or were you using TS and Sass. Integration with TS and Sass plugins isn't well tested at this point in time.

kubijo commented 4 years ago

I'm at TS and SASS for a very long time

eirikaho commented 4 years ago

I get a circular dependency detected in every file (even index.html) with webpack 5.1.3. Same with webpack 5.0.0. Working fine with webpack 4.44.2.

Error: Circular dependency detected: app/index.html -> app/index.html

akphi commented 4 years ago

@eirikaho might have to do with html-webpack-plugin if you're using it. But anyway, for me what I did was to only count JS/TS file using the include pattern include: /app.+\.(j|t)sx?$/,

aackerman commented 4 years ago

I'll take a look at webpack 5.1, but my tests are relatively thorough for integration with webpack 4.x.x and 5.0.0 with no other plugins. Which is what I've focused on so far.

If you are having an issue with how this plugin works in the presence of other plugins please include a listing of the specific webpack version, and versions of all webpack plugins, along with the specific output you are seeing which you feel is a bug.

xenobytezero commented 4 years ago

If it helps, my Lit Element starter repo is showing this problem

https://github.com/xenobytezero/lit-element-starter

I have commented out the plugin in the webpack.config.js, uncommenting should show the error we are seeing.

Webpack - 5.1.3 CircularDependencyPlugin - 5.2.0

C:\Projects>npm run build

> litcodejam@1.0.0 build C:\Projects
> webpack-cli  --mode=production

[webpack-cli] Compilation finished
assets by status 291 KiB [cached] 3 assets
Entrypoint main = main.css bundle.js 3 auxiliary assets
orphan modules 113 KiB [orphan] 16 modules
runtime modules 917 bytes 5 modules
code generated modules 245 KiB (javascript) 145 KiB (css/mini-extract) [code generated]
  cacheable modules 245 KiB
    modules by path ./src/ 3.96 KiB 4 modules
    modules by path ./node_modules/ 241 KiB
      ./node_modules/lit-element/lit-element.js + 16 modules 124 KiB [built] [code generated]
      ./node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js 117 KiB [built] [code generated]
    ./sass/index.scss 50 bytes [built] [code generated]
    ./assets/webcomponents_logo.png 73 bytes [built] [code generated]
  css modules 145 KiB
    css ./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[2]!./sass/index.scss 90 bytes [code generated]
    css ./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[2]!./sass/index.scss (1) 145 KiB [code generated]
    css ./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[2]!./src/appRoot.view.scss 124 bytes [code generated]

ERROR in Circular dependency detected:
src\appRoot.view.ts -> src\appRoot.view.ts

ERROR in Circular dependency detected:
src\components\basic.component.ts -> src\components\basic.component.ts
kubijo commented 4 years ago

FWIW a get theese now after I've revisited the webpack upgrade (just a snippet, there's hundreds of these):

ERROR in Circular dependency detected!
 * shared/res/constants/currencies-json.ts
 > shared/res/constants/currencies-json.ts

ERROR in Circular dependency detected!
 * shared/res/constants/languages-json.ts
 > shared/res/constants/languages-json.ts

ERROR in Circular dependency detected!
 * shared/res/constants/permissions-json.ts
 > shared/res/constants/permissions-json.ts
deej-split commented 4 years ago

fwiw, i'm also seeing this, also on every file in the repo. I turned off all plugins. I am running with node 12, and the following packages:

    "circular-dependency-plugin": "5.2.0",
    "webpack": "5.3.2",
    "webpack-cli": "4.1.0",
    "webpack-dev-server": "3.11.0",

My stripped down webpack file is:

const CircularDependencyPlugin = require('circular-dependency-plugin');

const config = {
  entry: {
    app: ['/Users/me/project/src/app/index.js'],
  },

  output: {
    filename: 'js/[name].bundle.js',
    publicPath: '/',
  },

  resolve: {
    modules: ['/Users/me/project/src', 'node_modules'],
    alias: {
      src: '/Users/me/project/src',
    },
    fallback: {
      fs: false,
    },
  },

  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        use: [
          {
            loader: 'babel-loader',
          },
        ],
        exclude: /(node_modules)/,
      },
    ],
  },
  plugins: [
    new CircularDependencyPlugin({
      exclude: /node_modules/,
      include: /src/,
      failOnError: true,
    }),
  ],
};

module.exports = config;

NOTE: I am running this with webpack serve. I haven't verified if I've got everything set to the optimal es5 or es6 module types.

I'm sorry that I don't have time right now to set up a demo repo. I'll try to take a look next sprint.

aackerman commented 4 years ago

I've just published 5.2.1. I have a good feeling that the new version will solve the issue everyone in this thread has experienced. I'll wait to close this until someone else can confirm.

tranvansang commented 4 years ago

@aackerman

I've installed 5.2.1 and confirmed the problem gone. I think you can close the issue.

Thanks for the work.

aackerman commented 4 years ago

Thanks @tranvansang

kubijo commented 4 years ago

@aackerman

So … I've tried to upgrade and I still get cycles with just two paths & both of them are the same module…

This is my plugin config

const CircularDependencyPlugin = require('circular-dependency-plugin');
plugins.development.push(
    new CircularDependencyPlugin({
        // exclude detection of files based on a RegExp
        exclude: /node_modules/,
        // add errors to webpack instead of warnings
        failOnError: false,
        // set the current working directory for displaying module paths
        cwd: paths.ui,
        /**
         * called for each module that is cyclical
         *
         * @example CLI output
         * Error in Circular dependency detected!
         *  * path/to/file/a.js
         *  → path/to/file/b.js
         *  → path/to/file/a.js
         */
        onDetected({
            // `paths` will be an Array of the relative module paths that make up the cycle
            paths: cyclePaths,
            compilation,
        }) {
            const err = new Error(`Circular dependency detected!\n * ${cyclePaths.join('\n → ')}`);
            compilation.warnings.push(err);
        },
    }),
);
ERROR in Circular dependency detected!
 * shared/types/payouts.tsx
 → shared/types/payouts.tsx

ERROR in Circular dependency detected!
 * shared/types/scalar.tsx
 → shared/types/scalar.tsx

ERROR in Circular dependency detected!
 * shared/types/workers.tsx
 → shared/types/workers.tsx

I don't get it really… what would help you find the culprit?

kubijo commented 4 years ago

Here's an excerpt from my yarn.lock (seemingly relevant ones)

"circular-dependency-plugin@npm:5.2.1":
  version: 5.2.1
  resolution: "circular-dependency-plugin@npm:5.2.1"
  peerDependencies:
    webpack: ">=4.0.1"
  checksum: 92ae6c048379417140db70ca1e8f41fa288039dcc4178198c0372370ab7d091dcde36b28bd4ac5378519b97007b17eaee6be055b003941ddbfbaed32654b2be8
  languageName: node
  linkType: hard

"webpack-bundle-analyzer@npm:3.9.0":
  version: 3.9.0
  resolution: "webpack-bundle-analyzer@npm:3.9.0"
  dependencies:
    acorn: ^7.1.1
    acorn-walk: ^7.1.1
    bfj: ^6.1.1
    chalk: ^2.4.1
    commander: ^2.18.0
    ejs: ^2.6.1
    express: ^4.16.3
    filesize: ^3.6.1
    gzip-size: ^5.0.0
    lodash: ^4.17.19
    mkdirp: ^0.5.1
    opener: ^1.5.1
    ws: ^6.0.0
  bin:
    webpack-bundle-analyzer: lib/bin/analyzer.js
  checksum: 3ec0daf957cc17143f73bf00113aa567b466d674baae68e6f9148dfb80bdcc81c94f6da9f8e8cbb7782a6161319efcccc4a013b3820d13993934818cce7650c0
  languageName: node
  linkType: hard

"webpack-cli@npm:4.1.0":
  version: 4.1.0
  resolution: "webpack-cli@npm:4.1.0"
  dependencies:
    "@webpack-cli/info": ^1.0.2
    "@webpack-cli/serve": ^1.0.1
    ansi-escapes: ^4.3.1
    colorette: ^1.2.1
    command-line-usage: ^6.1.0
    commander: ^6.0.0
    enquirer: ^2.3.4
    execa: ^4.0.0
    import-local: ^3.0.2
    interpret: ^2.0.0
    rechoir: ^0.7.0
    v8-compile-cache: ^2.1.0
    webpack-merge: ^4.2.2
  peerDependencies:
    "@webpack-cli/generate-loader": "*"
    "@webpack-cli/generate-plugin": "*"
    "@webpack-cli/init": "*"
    "@webpack-cli/migrate": "*"
    webpack: 4.x.x || 5.x.x
    webpack-bundle-analyzer: "*"
    webpack-dev-server: "*"
  peerDependenciesMeta:
    "@webpack-cli/generate-loader":
      optional: true
    "@webpack-cli/generate-plugin":
      optional: true
    "@webpack-cli/init":
      optional: true
    "@webpack-cli/migrate":
      optional: true
    webpack-bundle-analyzer:
      optional: true
    webpack-dev-server:
      optional: true
  bin:
    webpack-cli: bin/cli.js
  checksum: 70402fe84abd9efe24db5ee5d2f053f4e8d96bb76e61111bbeb89b50af031c5f52bef91d3c5f006da9f90cdda9e0e0aeb599b7ec4f28811917c3bad79880fd37
  languageName: node
  linkType: hard

…and this is a loader config that might be relevant

{
    test: /\.(js|jsx|ts|tsx)$/,
    exclude: /node_modules/,
    // Our sources & `node_modules` that require compilation
    include: [
        paths.ui,
        /node_modules\/d3-\w+/,
        /node_modules\/react-intl/,
        /node_modules\/intl-messageformat/,
        /node_modules\/intl-messageformat-parser/,
        /node_modules\/slushpool/,
    ],
    use: [
        getCacheLoaderConfig(JSON.stringify(settings)),
        {
            loader: 'babel-loader',
            options: { rootMode: 'upward', cacheDirectory: false },
        },
    ],
}

… and this is my babel.config.js

/* eslint-disable */

const paths = require('./conf/settings.paths');
const settings = require('./shared/res/constants/settings.json');

const presets = {
    react: [
        '@babel/preset-react',
        // TODO: This breaks in storybook & typescript, so let's wait…
        // { runtime: 'classic' },
    ],
    ts: [
        '@babel/preset-typescript',
        {
            isTSX: true,
            allExtensions: true,
            allowNamespaces: false,
        },
    ],
    env: {
        es: [
            '@babel/preset-env',
            {
                modules: false,
                loose: false,
                shippedProposals: true,
                useBuiltIns: 'entry',
                corejs: {
                    version: 3,
                    proposals: false,
                },
            },
        ],
        node: [
            '@babel/preset-env',
            {
                modules: 'commonjs',
                targets: { node: 'current' },
                loose: false,
                shippedProposals: true,
            },
        ],
    },
};

module.exports = {
    presets: [presets.react, presets.env.es, presets.ts],
    plugins: [
        ['./shared/dev/plugins/babel-i18n', { commentPreffix: 'translators:', rootPath: paths.ui }],
        '@babel/plugin-proposal-class-properties',
        '@babel/plugin-proposal-private-methods',
        '@babel/plugin-proposal-numeric-separator',
        '@babel/plugin-proposal-object-rest-spread',
        '@babel/plugin-proposal-private-property-in-object',
        '@babel/plugin-syntax-dynamic-import',
        '@babel/plugin-transform-react-jsx-source',
        'transform-inline-environment-variables',
        'react-hot-loader/babel',
        'macros',
    ],
    env: {
        development: {
            plugins: [['babel-plugin-typescript-to-proptypes', { forbidExtraProps: false }]],
        },
        production: {
            plugins: [
                '@babel/plugin-transform-react-constant-elements',
                'transform-remove-debugger',
                'transform-undefined-to-void',
                'lodash',
            ],
        },
        test: {
            presets: [presets.react, presets.env.node, presets.ts],
        },
        node: {
            presets: [presets.react, presets.env.node, presets.ts],
            plugins: [
                [
                    require.resolve('babel-plugin-module-resolver'),
                    {
                        root: [paths.ui, paths.uiShared],
                        extensions: ['.js', '.jsx', '.css', '.scss', '.json'],
                    },
                ],
                [
                    'transform-define',
                    {
                        'process.env.NODE_ENV': JSON.stringify(true),
                        __DEV__: JSON.stringify(false),
                        FEATURE_LTC_XMR_ACTIVATED: settings.LTC_XMR_ACTIVATED,
                        FEATURE_DEMO_ENABLED: settings.DEMO_LOGIN_ENABLED,
                    },
                ],
            ],
        },
    },
};
aackerman commented 4 years ago

@kubijo please try version 5.2.2. I discovered an issue that affected modules compiled with typescript. More generally this plugin will now ignore all circular dependencies where a module appears to be directly importing itself due to the way webpack internals codifies dependencies.

deej-split commented 4 years ago

@aackerman 5.2.2 worked for me! Thank you very much!