Skip to content

[Bug Report]: When a module serves as both an entry file and dynamically introduces dependencies, it can cause module grouping exceptions #2272

@NidMo

Description

@NidMo

Steps to reproduce

  1. Project Structure

    examples/import-meta/
    ├── a.ts
    ├── index.ts
    ├── farm.config.ts
    └── package.json
    
  2. index.ts

    console.log(new URL("./foo.txt", import.meta.url));
    
    function loadA() {
      import("./a").then((res) => {
        console.log("res:", res);
      });
    }
  3. a.ts

    export const msg = "hello from a";
  4. farm.config.ts
    (Make sure to explicitly set both index.ts and a.ts as entries.)

    export default {
      input: {
        main: "./index.ts",
        a: "./a.ts",
      },
    };
  5. Run the Build

Reproduce link

No response

What is actually happening?

Expected to optimize the entry type, but an error occurred:

thread '<unnamed>' panicked at crates/core/src/module/module_group.rs:47:51:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Rayon: detected unexpected panic; aborting

System Info

System:
    OS: macOS 26.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 78.56 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.17.1 - /Users/ming07/.nvm/versions/node/v22.17.1/bin/node
    Yarn: 1.22.5 - /Users/ming07/.yarn/bin/yarn
    npm: 10.9.2 - /Users/ming07/.nvm/versions/node/v22.17.1/bin/npm
    pnpm: 9.12.2 - /Users/ming07/Library/pnpm/pnpm
    Deno: 1.23.2 - /Users/ming07/.deno/bin/deno
    Watchman: 2023.04.10.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 143.0.7499.41
    Safari: 26.1
  npmPackages:
    @farmfe/core: workspace:* => 2.0.0-beta.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions