originjs / vite-plugin-federation

Module Federation for vite & rollup
Other
2.4k stars 242 forks source link

flattenModule breaks dependencies #571

Closed Sdju closed 9 months ago

Sdju commented 9 months ago

Versions

Reproduction

Steps to reproduce

1) Install a library (commonjs) that exports function as default. E.g dayjs 2) Make it a shared library 3) Import it and use as a function

What is Expected?

The dependency should work

What is actually happening?

%Name% isn't a function

Reason

function flattenModule(module, name) {
  if (module.default)
    module = Object.assign({}, module.default, module);
  moduleCache[name] = module;
  return module;
}

After flattenModule, if we have a function in module.default, it won't be a function anymore cause of Object.assign

HummerHead87 commented 9 months ago

fixed in 1.3.3 https://github.com/originjs/vite-plugin-federation/commit/d60c019b288eb00337e38661985850bf8b426d34