npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-remote-import

v1.1.1

Published

Import remote VUE component via url

Downloads

146

Readme

Introduction

This module is used for load remote VUE component via url. So you can use it in router, global or local component reference.

How it works

It'll use import-html-entry package to load html file, so html file just like a minifect descript of your component. And then it'll parse it in order to get html template, styles, and scripts. But for now only scripts is useful. Then it'll execute all scripts and get the result of execution. So you should return components object in remote component project. You can also return multiple components.

For example:

In vue router:

import remoteImport from 'vue-remote-import'

...
let router = new Router([
{
  path: '/login',
  name: 'login',
  component: () => remoteImport('http://domain/components/login/index.html')
}
])

index.html can be ommited, and you can also use other name for entry html filename.

If you return multiple components, so you can use remoteLoad('http://domain/components', 'login') to get the component you want.

Remote Component Development Notation

You should output index.html not only js. So that you can use webpack to split code into chunks, and also js filename can have hash support when component changed.

You should process __webpack_public_path__ so that the webpack public path can be applied on the fly. In order to do that, you can create a file maybe named public_path.js. And the content of it should be:

if (window.__REMOTE_WEBPACK_PUBLIC_PATH__) {
  // eslint-disable-next-line
  __webpack_public_path__ = window.__REMOTE_WEBPACK_PUBLIC_PATH__
}

The __REMOTE_WEBPACK_PUBLIC_PATH__ will be injected by vue-remote-import package when invoke remoteImport function. And you need to import it in your component entry file(e.g. main.js). Just like import './public-path'

A whole component entry file content could be:

import './public-path'
import HelloWorld from './components/HelloWorld.vue'

export {
  HelloWorld
}

Other examples for usage:

In global component definition: Vue.component(name, () => remoteImport('url')) or in local component definition:

components: {
  page: () => remoteImport('url')
}

How to use

Install vue-remote-import package:

npm install vue-remote-import

Import it:

import remoteImport from 'vue-remote-import';

Use it:

() => remoteImport('url') // for default export
() => remoteImport('url', componentName) // for common export