single-spa / vue-cli-plugin-single-spa

https://single-spa.js.org/docs/ecosystem-vue.html#vue-cli
21 stars 11 forks source link

webpack5 Uncaught TypeError: application 'xxx' died in status LOADING_SOURCE_CODE: Cannot read properties of undefined (reading 'meta') at autoPublicPath #46

Open Jarryxin opened 2 years ago

Jarryxin commented 2 years ago

after upgrade vue webpack5... error occurred.

(set libraryTarget = umd) https://github.com/single-spa/vue-cli-plugin-single-spa/blob/main/index.js#L26

npm run serve:standalone

invoked SystemJSPublicPathWebpackPlugin (https://github.com/single-spa/vue-cli-plugin-single-spa/blob/main/index.js#L33)

inner invoked

https://github.com/joeldenning/systemjs-webpack-interop/blob/main/auto-public-path/auto-public-path.js#L15

此处 __system_context__undefined,报错

image

Currently, I change vue.config.js, fllow:

const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  chainWebpack: config => {
    config.output.libraryTarget("system")
  },
})
Jarryxin commented 2 years ago

reproducing repo: https://github.com/Jarryxin/vue-spa-app

rrjohnson85 commented 2 years ago

@Jarryxin I was dealing with the same error after upgrading to v5 of the Vue CLI. Since it apparently uses Webpack 5, I don't think the SystemJSPublicPathWebpackPlugin is needed.

The following seemed to solve the error for me:

// vue.config.js
module.exports = {
  configureWebpack: {
    output: {
      libraryTarget: "system",
    },
  },
  chainWebpack: (config) => {
    if (config.plugins.has("SystemJSPublicPathWebpackPlugin")) {
      config.plugins.delete("SystemJSPublicPathWebpackPlugin");
    }
  },
  filenameHashing: false,
};
Roned commented 1 year ago

@Jarryxin I was dealing with the same error after upgrading to v5 of the Vue CLI. Since it apparently uses Webpack 5, I don't think the SystemJSPublicPathWebpackPlugin is needed.

The following seemed to solve the error for me:

// vue.config.js
module.exports = {
  configureWebpack: {
    output: {
      libraryTarget: "system",
    },
  },
  chainWebpack: (config) => {
    if (config.plugins.has("SystemJSPublicPathWebpackPlugin")) {
      config.plugins.delete("SystemJSPublicPathWebpackPlugin");
    }
  },
  filenameHashing: false,
};

thank you!!! delete SystemJSPublicPathWebpackPlugin, it works. love you!!