@wener/system
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

SystemJS

Utils for SystemJS

Browser env

import { addPreload, getGlobalSystem, loadBrowserSystem } from '@wener/system';
import { createNoopLogger } from '@wener/utils';

// use script load to avoid minify error - nextjs & swc minify make cause minify error
await loadBrowserSystem({ logger: createNoopLogger(), script: true });

// make external lib works with current react
const BuiltinModules = {
  react: () => import('react'),
  'react/jsx-runtime': () => import('react/jsx-runtime'),
  'react-dom': () => import('react-dom'),
  'react-dom/client': () => import('react-dom/client'),
};
Object.entries(BuiltinModules).map(([k, v]) => addPreload(k, v));

const System = getGlobalSystem();
// load through jsdelivr & ga.system.jspm.io
const { ErrorSuspenseBoundary } = await System.import('@wener/reaction');
console.log(`Result`, React.createElement(ErrorSuspenseBoundary));

Server env

import { getGlobalSystem } from '@wener/system';
import { loadServerSystem } from '@wener/system/server';
import { createNoopLogger } from '@wener/utils';

await loadServerSystem({ logger: createNoopLogger() });
const System = getGlobalSystem();
// load through jsdelivr & ga.system.jspm.io
const { default: React } = await System.import('react');
console.log(`React`, React.createElement('a'));

Links

Readme

Keywords

Package Sidebar

Install

npm i @wener/system

Weekly Downloads

0

Version

1.0.5

License

MIT

Unpacked Size

219 kB

Total Files

67

Last publish

Collaborators

  • wenerme