Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I get loads of 'Circular dependency' errors when bundling 'npm link' symlinked modules #5414

Closed
twilson90 opened this issue Mar 3, 2024 · 1 comment

Comments

@twilson90
Copy link

My project is located in C:/projects/my-project.
In there I ran npm link "C:/projects/another-project"
That allows me to import code from the other project.
But when I try using rollup on 'my-project', I get a load of errors that look like this:

Circular dependency: node_modules/core-js/modules/es.symbol.js -> C:/projects/my-project/node_modules/core-js/modules/es.symbol.constructor.js?commonjs-proxy -> node_modules/core-js/modules/es.symbol.constructor.js -> node_modules/core-js/modules/es.symbol.js

This is my script:

/**
  var plugins = [];
  plugins.push(
    rollup_plugin_node_resolve({browser: true}),
    rollup_plugin_commonjs({}),
    rollup_node_polyfills(),
  );
  var babel_presets = [
    [
      "@babel/preset-env", {
        "useBuiltIns": "usage",
        "corejs": "3"
      },
    ]
  ];
  var babel_plugins = [];
  plugins.push(
    rollup_plugin_babel({
      "babelHelpers": "bundled",
      "presets": babel_presets,
      "plugins": babel_plugins,
    })
  );

  try {
    await fs.mkdir(".rollup", {recursive:true});
    var options = {
      preserveSymlinks: true,
      input: filename,
      plugins,
    }
    var bundle = await rollup({...options, cache});
    var formats = ["iife"];
    for (let f of formats) {
      /** @type {import("rollup").OutputOptions} */
      let output = {
        "format": f,
        "file": out_filename,
        "name": name,
        "sourcemap": false,
      };
      await bundle.write(output);
    }
  } catch (e) {
    console.error(e);
  }
  console.log (`Rollup complete.`);

If I don't use 'preserveSymlinks' then it can't resolve all the corejs modules.

Any ideas how I can fix this?

@twilson90
Copy link
Author

I'd commented out "exclude": "node_modules/**" from my babel config. Adding that back in fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant