#1279·ncc

Unable to exclude modules

Author: odurand75Created Aug 15, 2025Updated Aug 15, 2025

Hi!

Trying to exclude a module in vain.

Steps to reproduce

> ncc build main.js -e module1 -o .\dist\

Actual result

  • The code from the excluded module is included in index.js
  • The module object is removed

Example

main.js

import * as module1 from './module1.mjs';

let myVar = module1.myFunction();

module1.mjs

bash
export function myFunction(){
    return null;
}

index.js

function myFunction(){
    return null;
}

let myVar = myFunction();

Expected results

  • The code from the excluded module is not included in index.js
  • The module object is left as is

Example

main.js

import * as module1 from './module1.mjs';

let myVar = module1.myFunction();

module1.mjs

bash
export function myFunction(){
    return null;
}

index.js

let myVar = module1.myFunction();

Notes:

  • Code is nodejs with ES Module imports / exports
  • Documentation is not clear as to how to declare module in the command line. I have tried to put the module name only, the module with the path, single quote, extension, etc...
  • Debug option (-d) does not seem to work easier (nothing displayed)
  • ncc version 0.38.3
  • My modules are named with the .mjs extension
  • I have also used JSDoc @module in the module header
  • Same result with the --external option