originjs / vite-plugin-federation

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

exporting variables from the shared module, the variables within the shared module appear as undefined #575

Open platec opened 8 months ago

platec commented 8 months ago

test.js

import { ref, onMounted } from 'vue';

export function test() {
  const dataSource = ref([]);

  onMounted(() => {
    dataSource.value = [1, 2, 3];
  });
}

export { h } from 'vue';

after vite building

import { importShared, __tla as __tla_0 } from "./__federation_fn_import-B4BZ4M9v.js";
let h, test;
let __tla = Promise.all([
  (() => {
    try {
      return __tla_0;
    } catch {
    }
  })()
]).then(async () => {
  const { ref, onMounted } = await importShared("vue");
  test = function() {
    const dataSource = ref([]);
    onMounted(() => {
      dataSource.value = [
        1,
        2,
        3
      ];
    });
  };
});
export {
  __tla,
  h,
  test
};
platec commented 8 months ago

related issue #496