distributed-vue-applications-loading-components-via-http icon indicating copy to clipboard operation
distributed-vue-applications-loading-components-via-http copied to clipboard

Can be used in vue3

Open CHENLiver opened this issue 3 years ago • 4 comments

An error occurred in the VUe3 project

1231645601931_ pic_hd

CHENLiver avatar Feb 23 '22 07:02 CHENLiver

I got working with [email protected] with following steps:

Add webpack configuration:

// vue.config.js

const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true,

  // Add this
  configureWebpack: config => {
   config.externals = { vue: 'Vue' }
 }

})

and then in index file

<!DOCTYPE html>
<html lang="">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
    <title><%= htmlWebpackPlugin.options.title %></title>

   // Add this line
    <script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>

  </head>
  <body>
    <noscript>
      <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
    </noscript>
    <div id="app"></div>
    <!-- built files will be auto injected -->
  </body>
</html>

annlumia avatar Aug 15 '22 08:08 annlumia

@annlumia Hi

That looks like you got it working with Vue 3, I'm trying to do everything same way (^3.2.37) and component downloads but not renders ever.

I have warning [Vue warn]: Invalid VNode type: undefined (undefined) if import component like this:

const MyComponent = () => externalComponent('[http://localhost:8080/MyComponent.b451c19a4e085013.umd.min.js’](http://localhost:8080/MyComponent.b451c19a4e085013.umd.min.js%E2%80%99))

or

I got [Vue warn]: Async component loader resolved to undefined. If you are using retry(), make sure to return its return value. when import async-way:

const MyComponent = defineAsyncComponent(() => externalComponent('http://localhost:8080/MyComponent.b451c19a4e085013.umd.min.js'))

I've tried yours code, but no difference at all. No new warnings or errors either. May be you can help where to look for?

regards, --Sofya :)

turtle-hobbit avatar Nov 01 '22 05:11 turtle-hobbit

@turtle-hobbit hai,

Sorry if my explanation is not clear. I've created a repository for a sample project I made, it might be easier.

vue3-distributed-component

annlumia avatar Nov 03 '22 07:11 annlumia

@annlumia

Thanks a lot for your help.

regards, --Sofya :)

turtle-hobbit avatar Nov 03 '22 10:11 turtle-hobbit