npm.io
1.4.45 • Published 1 year ago

@alicloud/console-os-loader

Licence
MIT
Version
1.4.45
Deps
5
Size
42 kB
Vulns
1
Weekly
0

Console OS Loader

An app bundle loader used by console os

TODO

  • load single bundle
  • script load error handler
  • recursive load
  • load with deps
  • combo load bundle

How to use

tnpm i @alicloud/console-os-loader
import { loadBundle } from '@alicloud/console-os-loader'

const vpc = await loadBundle({
  id: 'vpc',
  url: 'https://g.alicdn.com/aliyun-next/vpc/index.js'
})

External library

import react from 'react'
import { loadBundle } from '@alicloud/console-os-loader'

const vpc = await loadBundle(
  {
    id: 'vpc',
    url: 'https://g.alicdn.com/aliyun-next/vpc/index.js'
    deps: {
      react,
    }
  }
)

Build bundle

Webpack

in you webpack.config.js

const Chain = require('webpack-chain');
const merge = require('webpack-merge');
const { chainOsWebpack } = require('@alicloud/console-toolkit-plugin-os')

const chain = new Chain();
chainOsWebpack({ id: 'app-id' })(chain);
module.exports = merge(/*you webpack conf*/, chain.toConfig());
Consol OS Toolkit

In OS, an app bundle is built by breezr, you can use @alicloud/console-toolkit-plugin-os to build your bundle

/* breezr.config.js */

module.exports = {
  /*
   * other breezr config
   */
  plugins: [
    '@alicloud/console-toolkit-plugin-os'
  ]
}