rollup / rollup/rollup

merge a third-party dependencies into bundle files is not working

Open
#3,321 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

💩 template removed c⁵ ⋅ question
Dominant language
JavaScript
Stars
26.3k
Forks
1.8k
Avg merge
2d 11h
Merged PRs (30d)
20

Description

I want to merge the third dependency into the bundle file. According to the configuration of the official website, it does not take effect.
here is my code

rollup.config.js

import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
export default {
  input: "index.js",
  output: {
    file: "main.js",
    format: "iife"
  },
  plugins: [
    resolve({ mainFields: ["jsnext", "module", "main"],
   }),
    commonjs({
      include: "node_modules/**"
    })
  ]
};

index.js

import { CanvasRoot } from "react-webgl";

const cr = new CanvasRoot();

But when I bundle the file, I get thoese information
image

Here is the bundle file
main.js

(function (reactWebgl) {
	'use strict';

	const cr = new reactWebgl.CanvasRoot();

}(reactWebgl));

This has bothered me for two days,any tips wille be appreciated

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the configuration shown in rollup.config.js and the import in index.js, then inspect the generated main.js. Reproduce the bundle and compare the output with the stated goal of including the react-webgl dependency rather than leaving reactWebgl as an external reference.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.