@empjs/share 3.6.1-beta.2 → 3.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter.cjs.map +1 -1
- package/dist/adapter.js.map +1 -1
- package/dist/adapterVue.cjs.map +1 -1
- package/dist/adapterVue.js.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/rspack.cjs +2 -2
- package/dist/rspack.cjs.map +1 -1
- package/dist/rspack.js +2 -2
- package/dist/rspack.js.map +1 -1
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.js.map +1 -1
- package/output/sdk.js +1 -1
- package/output/sdk.js.map +1 -1
- package/package.json +37 -19
package/dist/adapter.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/adapter/index.ts","../src/helper/index.ts","../src/adapter/react.tsx"],"sourcesContent":["export * from 'src/adapter/react'\n","export const importJsVm = (content: string) => `data:text/javascript,${content}`\n\nexport function deepAssign<T>(target: any, ...sources: any): T {\n for (const source of sources) {\n for (const k in source) {\n const vs = source[k],\n vt = target[k]\n if (Object(vs) == vs && Object(vt) === vt) {\n target[k] = deepAssign(vt, vs)\n continue\n }\n target[k] = source[k]\n }\n }\n return target\n}\n\nexport const checkVersion = (version: string) => (version ? Number(version.split('.')[0]) : 0)\nexport const isPromise = (p: any) => p && Object.prototype.toString.call(p) === '[object Promise]'\n\n//\nexport const isDev = process.env.EMPSHARE_ENV === 'dev'\nexport const log = isDev ? console.log.bind(console, '[EMP Share]') : () => {}\n","import {checkVersion, isPromise} from 'src/helper'\nimport type {EMPShareRuntimeAdapterReactType, InitOptionsType} from 'src/types'\nimport {log} from '../helper'\n//\nlet globalLib = {}\nconst win: any = window\n//\nlog('process.env.EMPSHARE_ENV', process.env.EMPSHARE_ENV)\n//\nconst {EMPShareGlobalVal} = win || {}\nif (EMPShareGlobalVal && EMPShareGlobalVal.frameworkLib) {\n globalLib = win[EMPShareGlobalVal.frameworkLib]\n}\n//\nexport class ReactAdapter {\n libs: EMPShareRuntimeAdapterReactType = {\n scope: 'default',\n ...globalLib,\n }\n constructor(op?: EMPShareRuntimeAdapterReactType) {\n if (op) this.setup(op)\n }\n public setup(o?: EMPShareRuntimeAdapterReactType | string) {\n if (o) {\n if (typeof o === 'string') o = window[o]\n this.libs = {...this.libs, ...(o as any)}\n }\n }\n get shared(): InitOptionsType['shared'] {\n const {React, ReactDOM, scope} = this.libs as EMPShareRuntimeAdapterReactType\n return {\n react: {\n lib: () => React,\n version: React.version,\n scope,\n shareConfig: {\n singleton: true,\n requiredVersion: `^${React.version}`,\n },\n },\n 'react-dom': {\n lib: () => ReactDOM,\n version: ReactDOM.version,\n scope,\n shareConfig: {\n singleton: true,\n requiredVersion: `^${React.version}`,\n },\n },\n }\n }\n adapter<P = any>(\n component: any,\n scope: string = this.libs.scope,\n React: any = this.libs.React,\n ReactDOM: any = this.libs.ReactDOM,\n ): P {\n const reactVersion = checkVersion(React.version)\n const self = this\n class WrappedComponent extends React.Component {\n public containerRef: any\n public root: any\n constructor(props: P) {\n super(props as any)\n this.containerRef = React.createRef()\n }\n\n componentDidMount() {\n log('componentDidMount')\n this.mountOriginalComponent(true)\n }\n\n componentDidUpdate() {\n log('componentDidUpdate')\n this.mountOriginalComponent()\n }\n\n componentWillUnmount() {\n log('componentWillUnmount')\n this.unMountOriginalComponent()\n }\n unMountOriginalComponent() {\n if (!this.containerRef.current) return\n if (reactVersion < 18) {\n ReactDOM.unmountComponentAtNode(this.containerRef.current)\n } else {\n this.root.unmount()\n }\n }\n async mountOriginalComponent(shouldRender?: boolean) {\n if (isPromise(component))\n component = await component.then((m: any) => {\n return m[scope]\n })\n const element = React.createElement(component, this.props)\n\n if (reactVersion < 18) {\n const Render = shouldRender ? ReactDOM.render : ReactDOM.hydrate\n Render(element, this.containerRef.current)\n log('shouldRender16', shouldRender, reactVersion)\n } else {\n log('shouldRender18', shouldRender, reactVersion)\n if (shouldRender) {\n const {createRoot} = self.libs\n this.root = createRoot(this.containerRef.current!)\n this.root.render(element)\n } else {\n // const {hydrateRoot} = self.libs\n // this.root = hydrateRoot(this.containerRef.current!, element)\n this.root.render()\n }\n }\n }\n\n render() {\n return <div ref={this.containerRef} />\n }\n }\n return WrappedComponent as any\n }\n}\n\nexport const reactAdapter = new ReactAdapter()\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,EAAA,iBAAAC,IAAA,eAAAC,EAAAJ,GCiBO,IAAMK,EAAgBC,GAAqBA,EAAU,OAAOA,EAAQ,MAAM,GAAG,EAAE,CAAC,CAAC,EAAI,EAC/EC,EAAaC,GAAWA,GAAK,OAAO,UAAU,SAAS,KAAKA,CAAC,IAAM,mBAGnEC,EAAQ,GACRC,EAAMD,EAAQ,QAAQ,IAAI,KAAK,QAAS,aAAa,EAAI,IAAM,CAAC,
|
|
1
|
+
{"version":3,"sources":["../src/adapter/index.ts","../src/helper/index.ts","../src/adapter/react.tsx"],"sourcesContent":["export * from 'src/adapter/react'\n","export const importJsVm = (content: string) => `data:text/javascript,${content}`\n\nexport function deepAssign<T>(target: any, ...sources: any): T {\n for (const source of sources) {\n for (const k in source) {\n const vs = source[k],\n vt = target[k]\n if (Object(vs) == vs && Object(vt) === vt) {\n target[k] = deepAssign(vt, vs)\n continue\n }\n target[k] = source[k]\n }\n }\n return target\n}\n\nexport const checkVersion = (version: string) => (version ? Number(version.split('.')[0]) : 0)\nexport const isPromise = (p: any) => p && Object.prototype.toString.call(p) === '[object Promise]'\n\n//\nexport const isDev = process.env.EMPSHARE_ENV === 'dev'\nexport const log = isDev ? console.log.bind(console, '[EMP Share]') : () => {}\n","import {checkVersion, isPromise} from 'src/helper'\nimport type {EMPShareRuntimeAdapterReactType, InitOptionsType} from 'src/types'\nimport {log} from '../helper'\n\n//\nlet globalLib = {}\nconst win: any = window\n//\nlog('process.env.EMPSHARE_ENV', process.env.EMPSHARE_ENV)\n//\nconst {EMPShareGlobalVal} = win || {}\nif (EMPShareGlobalVal && EMPShareGlobalVal.frameworkLib) {\n globalLib = win[EMPShareGlobalVal.frameworkLib]\n}\n//\nexport class ReactAdapter {\n libs: EMPShareRuntimeAdapterReactType = {\n scope: 'default',\n ...globalLib,\n }\n constructor(op?: EMPShareRuntimeAdapterReactType) {\n if (op) this.setup(op)\n }\n public setup(o?: EMPShareRuntimeAdapterReactType | string) {\n if (o) {\n if (typeof o === 'string') o = window[o]\n this.libs = {...this.libs, ...(o as any)}\n }\n }\n get shared(): InitOptionsType['shared'] {\n const {React, ReactDOM, scope} = this.libs as EMPShareRuntimeAdapterReactType\n return {\n react: {\n lib: () => React,\n version: React.version,\n scope,\n shareConfig: {\n singleton: true,\n requiredVersion: `^${React.version}`,\n },\n },\n 'react-dom': {\n lib: () => ReactDOM,\n version: ReactDOM.version,\n scope,\n shareConfig: {\n singleton: true,\n requiredVersion: `^${React.version}`,\n },\n },\n }\n }\n adapter<P = any>(\n component: any,\n scope: string = this.libs.scope,\n React: any = this.libs.React,\n ReactDOM: any = this.libs.ReactDOM,\n ): P {\n const reactVersion = checkVersion(React.version)\n const self = this\n class WrappedComponent extends React.Component {\n public containerRef: any\n public root: any\n constructor(props: P) {\n super(props as any)\n this.containerRef = React.createRef()\n }\n\n componentDidMount() {\n log('componentDidMount')\n this.mountOriginalComponent(true)\n }\n\n componentDidUpdate() {\n log('componentDidUpdate')\n this.mountOriginalComponent()\n }\n\n componentWillUnmount() {\n log('componentWillUnmount')\n this.unMountOriginalComponent()\n }\n unMountOriginalComponent() {\n if (!this.containerRef.current) return\n if (reactVersion < 18) {\n ReactDOM.unmountComponentAtNode(this.containerRef.current)\n } else {\n this.root.unmount()\n }\n }\n async mountOriginalComponent(shouldRender?: boolean) {\n if (isPromise(component))\n component = await component.then((m: any) => {\n return m[scope]\n })\n const element = React.createElement(component, this.props)\n\n if (reactVersion < 18) {\n const Render = shouldRender ? ReactDOM.render : ReactDOM.hydrate\n Render(element, this.containerRef.current)\n log('shouldRender16', shouldRender, reactVersion)\n } else {\n log('shouldRender18', shouldRender, reactVersion)\n if (shouldRender) {\n const {createRoot} = self.libs\n this.root = createRoot(this.containerRef.current!)\n this.root.render(element)\n } else {\n // const {hydrateRoot} = self.libs\n // this.root = hydrateRoot(this.containerRef.current!, element)\n this.root.render()\n }\n }\n }\n\n render() {\n return <div ref={this.containerRef} />\n }\n }\n return WrappedComponent as any\n }\n}\n\nexport const reactAdapter = new ReactAdapter()\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,EAAA,iBAAAC,IAAA,eAAAC,EAAAJ,GCiBO,IAAMK,EAAgBC,GAAqBA,EAAU,OAAOA,EAAQ,MAAM,GAAG,EAAE,CAAC,CAAC,EAAI,EAC/EC,EAAaC,GAAWA,GAAK,OAAO,UAAU,SAAS,KAAKA,CAAC,IAAM,mBAGnEC,EAAQ,GACRC,EAAMD,EAAQ,QAAQ,IAAI,KAAK,QAAS,aAAa,EAAI,IAAM,CAAC,ECjB7E,IAAIE,EAAY,CAAC,EACXC,EAAW,OAEjBC,EAAI,2BAA4B,MAAwB,EAExD,GAAM,CAAC,kBAAAC,CAAiB,EAAIF,GAAO,CAAC,EAChCE,GAAqBA,EAAkB,eACzCH,EAAYC,EAAIE,EAAkB,YAAY,GAGzC,IAAMC,EAAN,KAAmB,CACxB,KAAwC,CACtC,MAAO,UACP,GAAGJ,CACL,EACA,YAAYK,EAAsC,CAC5CA,GAAI,KAAK,MAAMA,CAAE,CACvB,CACO,MAAMC,EAA8C,CACrDA,IACE,OAAOA,GAAM,WAAUA,EAAI,OAAOA,CAAC,GACvC,KAAK,KAAO,CAAC,GAAG,KAAK,KAAM,GAAIA,CAAS,EAE5C,CACA,IAAI,QAAoC,CACtC,GAAM,CAAC,MAAAC,EAAO,SAAAC,EAAU,MAAAC,CAAK,EAAI,KAAK,KACtC,MAAO,CACL,MAA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KAAK,aAAa,OAAQ,EACjD,KAAK,KAAK,OAAOD,CAAO,CAC1B,MAGE,KAAK,KAAK,OAAO,CAGvB,CAEA,QAAS,CACP,OAAOZ,EAAA,cAAC,OAAI,IAAK,KAAK,aAAc,CACtC,CACF,CACA,OAAOO,CACT,CACF,EAEaO,EAAe,IAAIjB","names":["adapter_exports","__export","ReactAdapter","reactAdapter","__toCommonJS","checkVersion","version","isPromise","p","isDev","log","globalLib","win","log","EMPShareGlobalVal","ReactAdapter","op","o","React","ReactDOM","scope","component","reactVersion","checkVersion","self","WrappedComponent","props","shouldRender","isPromise","m","element","createRoot","reactAdapter"]}
|
package/dist/adapter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/helper/index.ts","../src/adapter/react.tsx"],"sourcesContent":["export const importJsVm = (content: string) => `data:text/javascript,${content}`\n\nexport function deepAssign<T>(target: any, ...sources: any): T {\n for (const source of sources) {\n for (const k in source) {\n const vs = source[k],\n vt = target[k]\n if (Object(vs) == vs && Object(vt) === vt) {\n target[k] = deepAssign(vt, vs)\n continue\n }\n target[k] = source[k]\n }\n }\n return target\n}\n\nexport const checkVersion = (version: string) => (version ? Number(version.split('.')[0]) : 0)\nexport const isPromise = (p: any) => p && Object.prototype.toString.call(p) === '[object Promise]'\n\n//\nexport const isDev = process.env.EMPSHARE_ENV === 'dev'\nexport const log = isDev ? console.log.bind(console, '[EMP Share]') : () => {}\n","import {checkVersion, isPromise} from 'src/helper'\nimport type {EMPShareRuntimeAdapterReactType, InitOptionsType} from 'src/types'\nimport {log} from '../helper'\n//\nlet globalLib = {}\nconst win: any = window\n//\nlog('process.env.EMPSHARE_ENV', process.env.EMPSHARE_ENV)\n//\nconst {EMPShareGlobalVal} = win || {}\nif (EMPShareGlobalVal && EMPShareGlobalVal.frameworkLib) {\n globalLib = win[EMPShareGlobalVal.frameworkLib]\n}\n//\nexport class ReactAdapter {\n libs: EMPShareRuntimeAdapterReactType = {\n scope: 'default',\n ...globalLib,\n }\n constructor(op?: EMPShareRuntimeAdapterReactType) {\n if (op) this.setup(op)\n }\n public setup(o?: EMPShareRuntimeAdapterReactType | string) {\n if (o) {\n if (typeof o === 'string') o = window[o]\n this.libs = {...this.libs, ...(o as any)}\n }\n }\n get shared(): InitOptionsType['shared'] {\n const {React, ReactDOM, scope} = this.libs as EMPShareRuntimeAdapterReactType\n return {\n react: {\n lib: () => React,\n version: React.version,\n scope,\n shareConfig: {\n singleton: true,\n requiredVersion: `^${React.version}`,\n },\n },\n 'react-dom': {\n lib: () => ReactDOM,\n version: ReactDOM.version,\n scope,\n shareConfig: {\n singleton: true,\n requiredVersion: `^${React.version}`,\n },\n },\n }\n }\n adapter<P = any>(\n component: any,\n scope: string = this.libs.scope,\n React: any = this.libs.React,\n ReactDOM: any = this.libs.ReactDOM,\n ): P {\n const reactVersion = checkVersion(React.version)\n const self = this\n class WrappedComponent extends React.Component {\n public containerRef: any\n public root: any\n constructor(props: P) {\n super(props as any)\n this.containerRef = React.createRef()\n }\n\n componentDidMount() {\n log('componentDidMount')\n this.mountOriginalComponent(true)\n }\n\n componentDidUpdate() {\n log('componentDidUpdate')\n this.mountOriginalComponent()\n }\n\n componentWillUnmount() {\n log('componentWillUnmount')\n this.unMountOriginalComponent()\n }\n unMountOriginalComponent() {\n if (!this.containerRef.current) return\n if (reactVersion < 18) {\n ReactDOM.unmountComponentAtNode(this.containerRef.current)\n } else {\n this.root.unmount()\n }\n }\n async mountOriginalComponent(shouldRender?: boolean) {\n if (isPromise(component))\n component = await component.then((m: any) => {\n return m[scope]\n })\n const element = React.createElement(component, this.props)\n\n if (reactVersion < 18) {\n const Render = shouldRender ? ReactDOM.render : ReactDOM.hydrate\n Render(element, this.containerRef.current)\n log('shouldRender16', shouldRender, reactVersion)\n } else {\n log('shouldRender18', shouldRender, reactVersion)\n if (shouldRender) {\n const {createRoot} = self.libs\n this.root = createRoot(this.containerRef.current!)\n this.root.render(element)\n } else {\n // const {hydrateRoot} = self.libs\n // this.root = hydrateRoot(this.containerRef.current!, element)\n this.root.render()\n }\n }\n }\n\n render() {\n return <div ref={this.containerRef} />\n }\n }\n return WrappedComponent as any\n }\n}\n\nexport const reactAdapter = new ReactAdapter()\n"],"mappings":"AAiBO,IAAMA,EAAgBC,GAAqBA,EAAU,OAAOA,EAAQ,MAAM,GAAG,EAAE,CAAC,CAAC,EAAI,EAC/EC,EAAaC,GAAWA,GAAK,OAAO,UAAU,SAAS,KAAKA,CAAC,IAAM,mBAGnEC,EAAQ,GACRC,EAAMD,EAAQ,QAAQ,IAAI,KAAK,QAAS,aAAa,EAAI,IAAM,CAAC,
|
|
1
|
+
{"version":3,"sources":["../src/helper/index.ts","../src/adapter/react.tsx"],"sourcesContent":["export const importJsVm = (content: string) => `data:text/javascript,${content}`\n\nexport function deepAssign<T>(target: any, ...sources: any): T {\n for (const source of sources) {\n for (const k in source) {\n const vs = source[k],\n vt = target[k]\n if (Object(vs) == vs && Object(vt) === vt) {\n target[k] = deepAssign(vt, vs)\n continue\n }\n target[k] = source[k]\n }\n }\n return target\n}\n\nexport const checkVersion = (version: string) => (version ? Number(version.split('.')[0]) : 0)\nexport const isPromise = (p: any) => p && Object.prototype.toString.call(p) === '[object Promise]'\n\n//\nexport const isDev = process.env.EMPSHARE_ENV === 'dev'\nexport const log = isDev ? console.log.bind(console, '[EMP Share]') : () => {}\n","import {checkVersion, isPromise} from 'src/helper'\nimport type {EMPShareRuntimeAdapterReactType, InitOptionsType} from 'src/types'\nimport {log} from '../helper'\n\n//\nlet globalLib = {}\nconst win: any = window\n//\nlog('process.env.EMPSHARE_ENV', process.env.EMPSHARE_ENV)\n//\nconst {EMPShareGlobalVal} = win || {}\nif (EMPShareGlobalVal && EMPShareGlobalVal.frameworkLib) {\n globalLib = win[EMPShareGlobalVal.frameworkLib]\n}\n//\nexport class ReactAdapter {\n libs: EMPShareRuntimeAdapterReactType = {\n scope: 'default',\n ...globalLib,\n }\n constructor(op?: EMPShareRuntimeAdapterReactType) {\n if (op) this.setup(op)\n }\n public setup(o?: EMPShareRuntimeAdapterReactType | string) {\n if (o) {\n if (typeof o === 'string') o = window[o]\n this.libs = {...this.libs, ...(o as any)}\n }\n }\n get shared(): InitOptionsType['shared'] {\n const {React, ReactDOM, scope} = this.libs as EMPShareRuntimeAdapterReactType\n return {\n react: {\n lib: () => React,\n version: React.version,\n scope,\n shareConfig: {\n singleton: true,\n requiredVersion: `^${React.version}`,\n },\n },\n 'react-dom': {\n lib: () => ReactDOM,\n version: ReactDOM.version,\n scope,\n shareConfig: {\n singleton: true,\n requiredVersion: `^${React.version}`,\n },\n },\n }\n }\n adapter<P = any>(\n component: any,\n scope: string = this.libs.scope,\n React: any = this.libs.React,\n ReactDOM: any = this.libs.ReactDOM,\n ): P {\n const reactVersion = checkVersion(React.version)\n const self = this\n class WrappedComponent extends React.Component {\n public containerRef: any\n public root: any\n constructor(props: P) {\n super(props as any)\n this.containerRef = React.createRef()\n }\n\n componentDidMount() {\n log('componentDidMount')\n this.mountOriginalComponent(true)\n }\n\n componentDidUpdate() {\n log('componentDidUpdate')\n this.mountOriginalComponent()\n }\n\n componentWillUnmount() {\n log('componentWillUnmount')\n this.unMountOriginalComponent()\n }\n unMountOriginalComponent() {\n if (!this.containerRef.current) return\n if (reactVersion < 18) {\n ReactDOM.unmountComponentAtNode(this.containerRef.current)\n } else {\n this.root.unmount()\n }\n }\n async mountOriginalComponent(shouldRender?: boolean) {\n if (isPromise(component))\n component = await component.then((m: any) => {\n return m[scope]\n })\n const element = React.createElement(component, this.props)\n\n if (reactVersion < 18) {\n const Render = shouldRender ? ReactDOM.render : ReactDOM.hydrate\n Render(element, this.containerRef.current)\n log('shouldRender16', shouldRender, reactVersion)\n } else {\n log('shouldRender18', shouldRender, reactVersion)\n if (shouldRender) {\n const {createRoot} = self.libs\n this.root = createRoot(this.containerRef.current!)\n this.root.render(element)\n } else {\n // const {hydrateRoot} = self.libs\n // this.root = hydrateRoot(this.containerRef.current!, element)\n this.root.render()\n }\n }\n }\n\n render() {\n return <div ref={this.containerRef} />\n }\n }\n return WrappedComponent as any\n }\n}\n\nexport const reactAdapter = new ReactAdapter()\n"],"mappings":"AAiBO,IAAMA,EAAgBC,GAAqBA,EAAU,OAAOA,EAAQ,MAAM,GAAG,EAAE,CAAC,CAAC,EAAI,EAC/EC,EAAaC,GAAWA,GAAK,OAAO,UAAU,SAAS,KAAKA,CAAC,IAAM,mBAGnEC,EAAQ,GACRC,EAAMD,EAAQ,QAAQ,IAAI,KAAK,QAAS,aAAa,EAAI,IAAM,CAAC,ECjB7E,IAAIE,EAAY,CAAC,EACXC,EAAW,OAEjBC,EAAI,2BAA4B,MAAwB,EAExD,GAAM,CAAC,kBAAAC,CAAiB,EAAIF,GAAO,CAAC,EAChCE,GAAqBA,EAAkB,eACzCH,EAAYC,EAAIE,EAAkB,YAAY,GAGzC,IAAMC,EAAN,KAAmB,CACxB,KAAwC,CACtC,MAAO,UACP,GAAGJ,CACL,EACA,YAAYK,EAAsC,CAC5CA,GAAI,KAAK,MAAMA,CAAE,CACvB,CACO,MAAMC,EAA8C,CACrDA,IACE,OAAOA,GAAM,WAAUA,EAAI,OAAOA,CAAC,GACvC,KAAK,KAAO,CAAC,GAAG,KAAK,KAAM,GAAIA,CAAS,EAE5C,CACA,IAAI,QAAoC,CACtC,GAAM,CAAC,MAAAC,EAAO,SAAAC,EAAU,MAAAC,CAAK,EAAI,KAAK,KACtC,MAAO,CACL,MAAO,CACL,IAAK,IAAMF,EACX,QAASA,EAAM,QACf,MAAAE,EACA,YAAa,CACX,UAAW,GACX,gBAAiB,IAAIF,EAAM,OAAO,EACpC,CACF,EACA,YAAa,CACX,IAAK,IAAMC,EACX,QAASA,EAAS,QAClB,MAAAC,EACA,YAAa,CACX,UAAW,GACX,gBAAiB,IAAIF,EAAM,OAAO,EACpC,CACF,CACF,CACF,CACA,QACEG,EACAD,EAAgB,KAAK,KAAK,MAC1BF,EAAa,KAAK,KAAK,MACvBC,EAAgB,KAAK,KAAK,SACvB,CACH,IAAMG,EAAeC,EAAaL,EAAM,OAAO,EACzCM,EAAO,KACb,MAAMC,UAAyBP,EAAM,SAAU,CACtC,aACA,KACP,YAAYQ,EAAU,CACpB,MAAMA,CAAY,EAClB,KAAK,aAAeR,EAAM,UAAU,CACtC,CAEA,mBAAoB,CAClBL,EAAI,mBAAmB,EACvB,KAAK,uBAAuB,EAAI,CAClC,CAEA,oBAAqB,CACnBA,EAAI,oBAAoB,EACxB,KAAK,uBAAuB,CAC9B,CAEA,sBAAuB,CACrBA,EAAI,sBAAsB,EAC1B,KAAK,yBAAyB,CAChC,CACA,0BAA2B,CACpB,KAAK,aAAa,UACnBS,EAAe,GACjBH,EAAS,uBAAuB,KAAK,aAAa,OAAO,EAEzD,KAAK,KAAK,QAAQ,EAEtB,CACA,MAAM,uBAAuBQ,EAAwB,CAC/CC,EAAUP,CAAS,IACrBA,EAAY,MAAMA,EAAU,KAAMQ,GACzBA,EAAET,CAAK,CACf,GACH,IAAMU,EAAUZ,EAAM,cAAcG,EAAW,KAAK,KAAK,EAEzD,GAAIC,EAAe,IACFK,EAAeR,EAAS,OAASA,EAAS,SAClDW,EAAS,KAAK,aAAa,OAAO,EACzCjB,EAAI,iBAAkBc,EAAcL,CAAY,UAEhDT,EAAI,iBAAkBc,EAAcL,CAAY,EAC5CK,EAAc,CAChB,GAAM,CAAC,WAAAI,CAAU,EAAIP,EAAK,KAC1B,KAAK,KAAOO,EAAW,KAAK,aAAa,OAAQ,EACjD,KAAK,KAAK,OAAOD,CAAO,CAC1B,MAGE,KAAK,KAAK,OAAO,CAGvB,CAEA,QAAS,CACP,OAAOZ,EAAA,cAAC,OAAI,IAAK,KAAK,aAAc,CACtC,CACF,CACA,OAAOO,CACT,CACF,EAEaO,EAAe,IAAIjB","names":["checkVersion","version","isPromise","p","isDev","log","globalLib","win","log","EMPShareGlobalVal","ReactAdapter","op","o","React","ReactDOM","scope","component","reactVersion","checkVersion","self","WrappedComponent","props","shouldRender","isPromise","m","element","createRoot","reactAdapter"]}
|
package/dist/adapterVue.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/adapter/vue.ts"],"sourcesContent":["const globalVue3Cache: any = {vue: {defineComponent: null, h: null, ref: null}, increaseId: Date.now()}\nconst win = window as any\nfunction bindSlotContext(target: any, context: any) {\n return Object.keys(target).map(key => {\n const vnode = target[key]\n vnode.context = context\n return vnode\n })\n}\n\nfunction vue2ToVue3(WrapperComponent: any, wrapperId: string): any {\n const Vue2 = win.EMP_ADAPTER_VUE.Vue\n let vm: any\n return {\n mounted() {\n const slots = this.$slots ? bindSlotContext(this.$slots, this.__self) : null\n vm = new Vue2({\n render: (createElement: any) => {\n return createElement(\n WrapperComponent,\n {\n on: this.$attrs,\n attrs: this.$attrs,\n props: {...this.$props, ...this.$attrs},
|
|
1
|
+
{"version":3,"sources":["../src/adapter/vue.ts"],"sourcesContent":["const globalVue3Cache: any = {vue: {defineComponent: null, h: null, ref: null}, increaseId: Date.now()}\nconst win = window as any\nfunction bindSlotContext(target: any, context: any) {\n return Object.keys(target).map(key => {\n const vnode = target[key]\n vnode.context = context\n return vnode\n })\n}\n\nfunction vue2ToVue3(WrapperComponent: any, wrapperId: string): any {\n const Vue2 = win.EMP_ADAPTER_VUE.Vue\n let vm: any\n return {\n mounted() {\n const slots = this.$slots ? bindSlotContext(this.$slots, this.__self) : null\n vm = new Vue2({\n render: (createElement: any) => {\n return createElement(\n WrapperComponent,\n {\n on: this.$attrs,\n attrs: this.$attrs,\n props: {...this.$props, ...this.$attrs}, // 合并 props 和 attrs\n scopedSlots: this.$scopedSlots,\n },\n slots,\n )\n },\n })\n vm.$mount(`#${wrapperId}`)\n },\n // 继承原组件的所有 props 定义\n props: WrapperComponent.props || {},\n render() {\n vm && vm.$forceUpdate()\n },\n }\n}\n\nconst initVue2InVue3Adapter = (vue: any) => {\n globalVue3Cache.vue = vue\n}\n// 创建组件\nexport const Vue2InVue3Adapter = (() => {\n initVue2InVue3Adapter(win.Vue)\n const {defineComponent, h, ref} = globalVue3Cache.vue\n if (!(defineComponent && h && ref)) {\n console.warn('emp3 Vue2InVue3Adapter has not init')\n return () => {}\n }\n return defineComponent({\n // 声明props\n props: {\n mfComponent: {\n type: Function,\n required: true,\n },\n },\n setup() {\n const renderId = ref(globalVue3Cache.increaseId)\n globalVue3Cache.increaseId++\n return {\n renderId,\n }\n },\n render() {\n const {renderId} = this\n return h('div', [h('div', {id: `vue2-in-vue3${renderId}`})])\n },\n mounted() {\n ;(async () => {\n const fc = await this.mfComponent()\n vue2ToVue3(fc.default, `vue2-in-vue3${this.renderId}`).mounted()\n })()\n },\n })\n})()\n\n// const Vue3InVue2Adapter = () => {\n// console.log('not implement')\n// }\n\n// export default {Vue2InVue3Adapter, Vue3InVue2Adapter}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAMI,EAAuB,CAAC,IAAK,CAAC,gBAAiB,KAAM,EAAG,KAAM,IAAK,IAAI,EAAG,WAAY,KAAK,IAAI,CAAC,EAChGC,EAAM,OACZ,SAASC,EAAgBC,EAAaC,EAAc,CAClD,OAAO,OAAO,KAAKD,CAAM,EAAE,IAAIE,GAAO,CACpC,IAAMC,EAAQH,EAAOE,CAAG,EACxB,OAAAC,EAAM,QAAUF,EACTE,CACT,CAAC,CACH,CAEA,SAASC,EAAWC,EAAuBC,EAAwB,CACjE,IAAMC,EAAOT,EAAI,gBAAgB,IAC7BU,EACJ,MAAO,CACL,SAAU,CACR,IAAMC,EAAQ,KAAK,OAASV,EAAgB,KAAK,OAAQ,KAAK,MAAM,EAAI,KACxES,EAAK,IAAID,EAAK,CACZ,OAASG,GACAA,EACLL,EACA,CACE,GAAI,KAAK,OACT,MAAO,KAAK,OACZ,MAAO,CAAC,GAAG,KAAK,OAAQ,GAAG,KAAK,MAAM,EACtC,YAAa,KAAK,YACpB,EACAI,CACF,CAEJ,CAAC,EACDD,EAAG,OAAO,IAAIF,CAAS,EAAE,CAC3B,EAEA,MAAOD,EAAiB,OAAS,CAAC,EAClC,QAAS,CACPG,GAAMA,EAAG,aAAa,CACxB,CACF,CACF,CAEA,IAAMG,EAAyBC,GAAa,CAC1Cf,EAAgB,IAAMe,CACxB,EAEajB,GAAqB,IAAM,CACtCgB,EAAsBb,EAAI,GAAG,EAC7B,GAAM,CAAC,gBAAAe,EAAiB,EAAAC,EAAG,IAAAC,CAAG,EAAIlB,EAAgB,IAClD,OAAMgB,GAAmBC,GAAKC,EAIvBF,EAAgB,CAErB,MAAO,CACL,YAAa,CACX,KAAM,SACN,SAAU,EACZ,CACF,EACA,OAAQ,CACN,IAAMG,EAAWD,EAAIlB,EAAgB,UAAU,EAC/C,OAAAA,EAAgB,aACT,CACL,SAAAmB,CACF,CACF,EACA,QAAS,CACP,GAAM,CAAC,SAAAA,CAAQ,EAAI,KACnB,OAAOF,EAAE,MAAO,CAACA,EAAE,MAAO,CAAC,GAAI,eAAeE,CAAQ,EAAE,CAAC,CAAC,CAAC,CAC7D,EACA,SAAU,EACN,SAAY,CACZ,IAAMC,EAAK,MAAM,KAAK,YAAY,EAClCb,EAAWa,EAAG,QAAS,eAAe,KAAK,QAAQ,EAAE,EAAE,QAAQ,CACjE,GAAG,CACL,CACF,CAAC,GA5BC,QAAQ,KAAK,qCAAqC,EAC3C,IAAM,CAAC,EA4BlB,GAAG","names":["vue_exports","__export","Vue2InVue3Adapter","__toCommonJS","globalVue3Cache","win","bindSlotContext","target","context","key","vnode","vue2ToVue3","WrapperComponent","wrapperId","Vue2","vm","slots","createElement","initVue2InVue3Adapter","vue","defineComponent","h","ref","renderId","fc"]}
|
package/dist/adapterVue.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/adapter/vue.ts"],"sourcesContent":["const globalVue3Cache: any = {vue: {defineComponent: null, h: null, ref: null}, increaseId: Date.now()}\nconst win = window as any\nfunction bindSlotContext(target: any, context: any) {\n return Object.keys(target).map(key => {\n const vnode = target[key]\n vnode.context = context\n return vnode\n })\n}\n\nfunction vue2ToVue3(WrapperComponent: any, wrapperId: string): any {\n const Vue2 = win.EMP_ADAPTER_VUE.Vue\n let vm: any\n return {\n mounted() {\n const slots = this.$slots ? bindSlotContext(this.$slots, this.__self) : null\n vm = new Vue2({\n render: (createElement: any) => {\n return createElement(\n WrapperComponent,\n {\n on: this.$attrs,\n attrs: this.$attrs,\n props: {...this.$props, ...this.$attrs},
|
|
1
|
+
{"version":3,"sources":["../src/adapter/vue.ts"],"sourcesContent":["const globalVue3Cache: any = {vue: {defineComponent: null, h: null, ref: null}, increaseId: Date.now()}\nconst win = window as any\nfunction bindSlotContext(target: any, context: any) {\n return Object.keys(target).map(key => {\n const vnode = target[key]\n vnode.context = context\n return vnode\n })\n}\n\nfunction vue2ToVue3(WrapperComponent: any, wrapperId: string): any {\n const Vue2 = win.EMP_ADAPTER_VUE.Vue\n let vm: any\n return {\n mounted() {\n const slots = this.$slots ? bindSlotContext(this.$slots, this.__self) : null\n vm = new Vue2({\n render: (createElement: any) => {\n return createElement(\n WrapperComponent,\n {\n on: this.$attrs,\n attrs: this.$attrs,\n props: {...this.$props, ...this.$attrs}, // 合并 props 和 attrs\n scopedSlots: this.$scopedSlots,\n },\n slots,\n )\n },\n })\n vm.$mount(`#${wrapperId}`)\n },\n // 继承原组件的所有 props 定义\n props: WrapperComponent.props || {},\n render() {\n vm && vm.$forceUpdate()\n },\n }\n}\n\nconst initVue2InVue3Adapter = (vue: any) => {\n globalVue3Cache.vue = vue\n}\n// 创建组件\nexport const Vue2InVue3Adapter = (() => {\n initVue2InVue3Adapter(win.Vue)\n const {defineComponent, h, ref} = globalVue3Cache.vue\n if (!(defineComponent && h && ref)) {\n console.warn('emp3 Vue2InVue3Adapter has not init')\n return () => {}\n }\n return defineComponent({\n // 声明props\n props: {\n mfComponent: {\n type: Function,\n required: true,\n },\n },\n setup() {\n const renderId = ref(globalVue3Cache.increaseId)\n globalVue3Cache.increaseId++\n return {\n renderId,\n }\n },\n render() {\n const {renderId} = this\n return h('div', [h('div', {id: `vue2-in-vue3${renderId}`})])\n },\n mounted() {\n ;(async () => {\n const fc = await this.mfComponent()\n vue2ToVue3(fc.default, `vue2-in-vue3${this.renderId}`).mounted()\n })()\n },\n })\n})()\n\n// const Vue3InVue2Adapter = () => {\n// console.log('not implement')\n// }\n\n// export default {Vue2InVue3Adapter, Vue3InVue2Adapter}\n"],"mappings":"AAAA,IAAMA,EAAuB,CAAC,IAAK,CAAC,gBAAiB,KAAM,EAAG,KAAM,IAAK,IAAI,EAAG,WAAY,KAAK,IAAI,CAAC,EAChGC,EAAM,OACZ,SAASC,EAAgBC,EAAaC,EAAc,CAClD,OAAO,OAAO,KAAKD,CAAM,EAAE,IAAIE,GAAO,CACpC,IAAMC,EAAQH,EAAOE,CAAG,EACxB,OAAAC,EAAM,QAAUF,EACTE,CACT,CAAC,CACH,CAEA,SAASC,EAAWC,EAAuBC,EAAwB,CACjE,IAAMC,EAAOT,EAAI,gBAAgB,IAC7BU,EACJ,MAAO,CACL,SAAU,CACR,IAAMC,EAAQ,KAAK,OAASV,EAAgB,KAAK,OAAQ,KAAK,MAAM,EAAI,KACxES,EAAK,IAAID,EAAK,CACZ,OAASG,GACAA,EACLL,EACA,CACE,GAAI,KAAK,OACT,MAAO,KAAK,OACZ,MAAO,CAAC,GAAG,KAAK,OAAQ,GAAG,KAAK,MAAM,EACtC,YAAa,KAAK,YACpB,EACAI,CACF,CAEJ,CAAC,EACDD,EAAG,OAAO,IAAIF,CAAS,EAAE,CAC3B,EAEA,MAAOD,EAAiB,OAAS,CAAC,EAClC,QAAS,CACPG,GAAMA,EAAG,aAAa,CACxB,CACF,CACF,CAEA,IAAMG,EAAyBC,GAAa,CAC1Cf,EAAgB,IAAMe,CACxB,EAEaC,GAAqB,IAAM,CACtCF,EAAsBb,EAAI,GAAG,EAC7B,GAAM,CAAC,gBAAAgB,EAAiB,EAAAC,EAAG,IAAAC,CAAG,EAAInB,EAAgB,IAClD,OAAMiB,GAAmBC,GAAKC,EAIvBF,EAAgB,CAErB,MAAO,CACL,YAAa,CACX,KAAM,SACN,SAAU,EACZ,CACF,EACA,OAAQ,CACN,IAAMG,EAAWD,EAAInB,EAAgB,UAAU,EAC/C,OAAAA,EAAgB,aACT,CACL,SAAAoB,CACF,CACF,EACA,QAAS,CACP,GAAM,CAAC,SAAAA,CAAQ,EAAI,KACnB,OAAOF,EAAE,MAAO,CAACA,EAAE,MAAO,CAAC,GAAI,eAAeE,CAAQ,EAAE,CAAC,CAAC,CAAC,CAC7D,EACA,SAAU,EACN,SAAY,CACZ,IAAMC,EAAK,MAAM,KAAK,YAAY,EAClCd,EAAWc,EAAG,QAAS,eAAe,KAAK,QAAQ,EAAE,EAAE,QAAQ,CACjE,GAAG,CACL,CACF,CAAC,GA5BC,QAAQ,KAAK,qCAAqC,EAC3C,IAAM,CAAC,EA4BlB,GAAG","names":["globalVue3Cache","win","bindSlotContext","target","context","key","vnode","vue2ToVue3","WrapperComponent","wrapperId","Vue2","vm","slots","createElement","initVue2InVue3Adapter","vue","Vue2InVue3Adapter","defineComponent","h","ref","renderId","fc"]}
|
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var u=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var M=(i,e)=>{for(var t in e)u(i,t,{get:e[t],enumerable:!0})},P=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of E(e))!S.call(i,n)&&n!==t&&u(i,n,{get:()=>e[n],enumerable:!(r=x(e,n))||r.enumerable});return i};var
|
|
2
|
-
`);return b(e)},l=class{options;constructor(e){this.options=e}apply(e){let{webpack:t}=e,r=O("@empjs/share/library");new t.EntryPlugin(e.context,r,{name:void 0}).apply(e)}};function g(i,e,t="runtime"){return typeof i=="string"?t==="runtime"?`${i}/runtime${e==="development"?".development":""}.umd.js`:`${i}/${t}.${e}.umd.js`:typeof i=="object"?e==="development"?i.dev:i.prod:""}var j=/^([0-9a-zA-Z_\s]+)@(.*)/,c=class{op;store;injectHtml=[];externalsLib=[];constructor(e,t){this.op=e||{},this.store=t}setup(){this.resetRuntime(),this.resetFramework(),this.setMfName(),this.setMF(),this.injectGlobalVal(),this.injectFramework(),this.setShareLib(),this.setRuntimeLib(),this.injectToHtml(),this.setExternal()}injectToHtml(){let{store:e,injectHtml:t}=this;t.length>0&&e.injectTags(t,"EMPShare")}injectFramework(){if(this.fk.libs.length>0)return this.injectFkLibs(this.fk.libs);if(!this.op.empRuntime||!this.fk.lib)return;let{store:e,injectHtml:t}=this;if(this.fk.lib){let r=g(this.fk.lib,e.mode,this.fk.entry);t.push({attributes:{src:r},tagName:"script"})}}injectFkLibs(e){e.map(t=>{if(t.endsWith(".css"))return this.injectHtml.push({attributes:{href:t,rel:"stylesheet"},tagName:"link"});this.injectHtml.push({attributes:{src:t},tagName:"script"})})}injectGlobalVal(){if(!this.op.empRuntime)return;let{empRuntime:e}=this.op,{injectHtml:t}=this,r=this.fk.global||(e.shareLib?"window":"");if(!(e.injectGlobalValToHtml===!1||!this.rt.lib)){let o={frameworkLib:r,runtimeLib:this.rt.global};this.fk.name&&this.fk.name!=="none"&&(o.framework=this.fk.name),t.push({tagName:"script",innerHTML:`EMPShareGlobalVal=${JSON.stringify(o)}`})}}fk;resetFramework(){if(!this.op.empRuntime)return;let{framework:e,frameworkGlobal:t,frameworkLib:r}=this.op.empRuntime;this.fk={name:"none",version:0,entry:"",global:t||"",lib:r||"",libs:[]},typeof e=="string"?this.fk.name=e:typeof e=="object"&&Object.keys(e).length>0&&(e.entry=e.entry?e.entry:e.name,this.fk=f(this.fk,e))}rt;resetRuntime(){let{empRuntime:e}=this.op;if(!e)return;let t=e.runtimeGlobal||y,r=e.runtimeLib?e.runtimeLib:e.runtime?.lib?e.runtime.lib:"";this.rt={lib:r,global:t}}setExternal(){if(!this.op.empRuntime)return;let{store:e,externalsLib:t}=this,{empRuntime:r}=this.op,{shareLib:n}=r,o=this.rt.lib?{"@module-federation/runtime":"MFRuntime","@module-federation/sdk":"MFSDK"}:{},s={};for(let[a,m]of Object.entries(o))s[a]=`${this.rt.global}.${m}`;if(this.fk.name==="react"&&!n&&this.fk.global){let a=this.fk.version,m={react:"React","react-dom":"ReactDOM"};this.fk.entry==="reactRouter"&&(m["react-router-dom"]="ReactRouterDOM");for(let[p,
|
|
1
|
+
"use strict";var u=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var M=(i,e)=>{for(var t in e)u(i,t,{get:e[t],enumerable:!0})},P=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of E(e))!S.call(i,n)&&n!==t&&u(i,n,{get:()=>e[n],enumerable:!(r=x(e,n))||r.enumerable});return i};var v=i=>P(u({},"__esModule",{value:!0}),i);var w={};M(w,{default:()=>T,externalReact:()=>H,externalVue:()=>N,pluginRspackEmpShare:()=>d});module.exports=v(w);var b=i=>`data:text/javascript,${i}`;function f(i,...e){for(let t of e)for(let r in t){let n=t[r],o=i[r];if(Object(n)==n&&Object(o)===o){i[r]=f(o,n);continue}i[r]=t[r]}return i}var L=!1,G=L?console.log.bind(console,"[EMP Share]"):()=>{};var y="EMP_SHARE_RUNTIME";var h=require("@module-federation/enhanced/rspack");var O=i=>{let e=[`import '${i}'`].join(`
|
|
2
|
+
`);return b(e)},l=class{options;constructor(e){this.options=e}apply(e){let{webpack:t}=e,r=O("@empjs/share/library");new t.EntryPlugin(e.context,r,{name:void 0}).apply(e)}};function g(i,e,t="runtime"){return typeof i=="string"?t==="runtime"?`${i}/runtime${e==="development"?".development":""}.umd.js`:`${i}/${t}.${e}.umd.js`:typeof i=="object"?e==="development"?i.dev:i.prod:""}var j=/^([0-9a-zA-Z_\s]+)@(.*)/,c=class{op;store;injectHtml=[];externalsLib=[];constructor(e,t){this.op=e||{},this.store=t}setup(){this.resetRuntime(),this.resetFramework(),this.setMfName(),this.setMF(),this.injectGlobalVal(),this.injectFramework(),this.setShareLib(),this.setRuntimeLib(),this.injectToHtml(),this.setExternal()}injectToHtml(){let{store:e,injectHtml:t}=this;t.length>0&&e.injectTags(t,"EMPShare")}injectFramework(){if(this.fk&&this.fk.libs.length>0)return this.injectFkLibs(this.fk.libs);if(!this.op.empRuntime||!this.fk.lib)return;let{store:e,injectHtml:t}=this;if(this.fk.lib){let r=g(this.fk.lib,e.mode,this.fk.entry);t.push({attributes:{src:r},tagName:"script"})}}injectFkLibs(e){e.map(t=>{if(t.endsWith(".css"))return this.injectHtml.push({attributes:{href:t,rel:"stylesheet"},tagName:"link"});this.injectHtml.push({attributes:{src:t},tagName:"script"})})}injectGlobalVal(){if(!this.op.empRuntime)return;let{empRuntime:e}=this.op,{injectHtml:t}=this,r=this.fk.global||(e.shareLib?"window":"");if(!(e.injectGlobalValToHtml===!1||!this.rt.lib)){let o={frameworkLib:r,runtimeLib:this.rt.global};this.fk.name&&this.fk.name!=="none"&&(o.framework=this.fk.name),t.push({tagName:"script",innerHTML:`EMPShareGlobalVal=${JSON.stringify(o)}`})}}fk;resetFramework(){if(!this.op.empRuntime)return;let{framework:e,frameworkGlobal:t,frameworkLib:r}=this.op.empRuntime;this.fk={name:"none",version:0,entry:"",global:t||"",lib:r||"",libs:[]},typeof e=="string"?this.fk.name=e:typeof e=="object"&&Object.keys(e).length>0&&(e.entry=e.entry?e.entry:e.name,this.fk=f(this.fk,e))}rt;resetRuntime(){let{empRuntime:e}=this.op;if(!e)return;let t=e.runtimeGlobal||y,r=e.runtimeLib?e.runtimeLib:e.runtime?.lib?e.runtime.lib:"";this.rt={lib:r,global:t}}setExternal(){if(!this.op.empRuntime)return;let{store:e,externalsLib:t}=this,{empRuntime:r}=this.op,{shareLib:n}=r,o=this.rt.lib?{"@module-federation/runtime":"MFRuntime","@module-federation/sdk":"MFSDK"}:{},s={};for(let[a,m]of Object.entries(o))s[a]=`${this.rt.global}.${m}`;if(this.fk.name==="react"&&!n&&this.fk.global){let a=this.fk.version,m={react:"React","react-dom":"ReactDOM"};this.fk.entry==="reactRouter"&&(m["react-router-dom"]="ReactRouterDOM");for(let[p,R]of Object.entries(m))s[p]=`${this.fk.global}.${R}`;[17,18,19].includes(a)&&(s["react-dom/client"]=this.fk.global,s["react/jsx-runtime"]=this.fk.global,s["react/jsx-dev-runtime"]=this.fk.global)}n&&t.map(a=>{a.type==="js"&&a.module&&a.global&&(s[a.module]=`${this.fk.global}.${a.global}`)}),r.setExternals&&r.setExternals(s,this.fk.global,this.rt.global),e.chain.merge({externals:s})}setRuntimeLib(){if(!this.op.empRuntime)return;let{shareLib:e}=this.op.empRuntime,{store:t,injectHtml:r}=this,{empRuntime:n}=this.op;this.rt.lib?this.rt.lib==="useFrameworkLib"&&!e||r.push({tagName:"script",pos:"head",attributes:{src:this.rt.lib}}):t.chain.plugin("plugin-emp-share-framework").use(l,[n])}setMfName(){this.op.name?(this.op.name=this.store.encodeVarName(this.op.name),this.op.name!==this.store.empConfig.output.uniqueName&&this.store.chain.output.set("uniqueName",this.op.name)):this.op.name=this.store.empConfig.output.uniqueName}setMF(){let e=this.op,{store:t}=this;if(e.name){let r=t.deepAssign({filename:"emp.js",manifest:!1,dts:!1,dev:{disableDynamicRemoteTypeHints:!0}},e);e.dev===!1&&(r.dev=!1),r.empRuntime&&delete r.empRuntime,t.chain.plugin("plugin-emp-share").use(h.ModuleFederationPlugin,[r])}}setShareLib(){if(!this.op.empRuntime)return;let{shareLib:e}=this.op.empRuntime,{externalsLib:t,injectHtml:r}=this;if(e&&typeof e=="object"){for(let[n,o]of Object.entries(e)){let s={};if(s.module=n,typeof o=="string"){let a=o.match(j)||[];a.length>0?(s.global=a[1],s.entry=a[2],s.type="js",t.push(s),s={}):(s.global="",s.entry=o,s.type="js",t.push(s),s={})}else Array.isArray(o)?o.map(a=>{if(!a)return;if(a.split("?")[0].endsWith(".css"))s.entry=a,s.type="css";else{let p=a.match(j)||[];p.length>0?(s.global=p[1],s.entry=p[2],s.type="js"):(s.global="",s.entry=a,s.type="js")}t.push(s),s={}}):typeof o=="object"&&o.entry&&(s.entry=o.entry,s.global=o.global,s.type=o.type,t.push(s),s={})}t.map(n=>{n.type==="js"?r.push({attributes:{src:n.entry},tagName:"script"}):n.type==="css"&&r.push({attributes:{href:n.entry,rel:"stylesheet"},tagName:"link"})})}}};var H=(i,e)=>(i=Object.assign(i,{react:`${e}.React`,"react-dom":`${e}.ReactDOM`,"react-dom/client":e,"react/jsx-runtime":e,"react/jsx-dev-runtime":e,"react-router-dom":`${e}.ReactRouterDOM`}),i);var N=(i,e)=>(i=Object.assign(i,{vue:`${e}.Vue`,"vue-router":`${e}.VueRouter`}),i);var d=(i={})=>({name:"@empjs/share",async rsConfig(e){i.manifest===!0?i.manifest={fileName:"emp.json"}:typeof i.manifest=="object"&&(i.manifest=e.deepAssign({fileName:"emp.json"},i.manifest)),new c(i,e).setup()}}),k=d;var T=k;0&&(module.exports={externalReact,externalVue,pluginRspackEmpShare});
|
|
3
3
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/helper/index.ts","../src/helper/config.ts","../src/helper/rspack.ts","../src/plugins/rspack/plugin.ts","../src/plugins/rspack/utils.ts","../src/plugins/rspack/share.ts","../src/framework/react/config.ts","../src/framework/vue/config.ts","../src/plugins/rspack/index.ts"],"sourcesContent":["import {default as pluginRspackEmpShare} from 'src/plugins/rspack'\nexport default pluginRspackEmpShare\nexport * from 'src/plugins/rspack'\n","export const importJsVm = (content: string) => `data:text/javascript,${content}`\n\nexport function deepAssign<T>(target: any, ...sources: any): T {\n for (const source of sources) {\n for (const k in source) {\n const vs = source[k],\n vt = target[k]\n if (Object(vs) == vs && Object(vt) === vt) {\n target[k] = deepAssign(vt, vs)\n continue\n }\n target[k] = source[k]\n }\n }\n return target\n}\n\nexport const checkVersion = (version: string) => (version ? Number(version.split('.')[0]) : 0)\nexport const isPromise = (p: any) => p && Object.prototype.toString.call(p) === '[object Promise]'\n\n//\nexport const isDev = process.env.EMPSHARE_ENV === 'dev'\nexport const log = isDev ? console.log.bind(console, '[EMP Share]') : () => {}\n","export const shareGlobalName = 'EMP_SHARE_RUNTIME'\n","export {ModuleFederationPlugin} from '@module-federation/enhanced/rspack'\n","import type {Compiler} from '@rspack/core'\nimport {importJsVm} from 'src/helper'\nimport type {EMPSHARERuntimeOptions} from './types'\nconst getShareRuntimeEntry = url => {\n const content = [`import '${url}'`].join('\\n')\n return importJsVm(content)\n}\n// 当没有设置 runtimeLib 时候需要内置\nexport class EmpShareRemoteLibPlugin {\n options: EMPSHARERuntimeOptions\n constructor(op: EMPSHARERuntimeOptions) {\n this.options = op\n }\n apply(compiler: Compiler) {\n const {webpack} = compiler\n const entry = getShareRuntimeEntry('@empjs/share/library')\n new webpack.EntryPlugin(compiler.context, entry, {\n name: undefined,\n }).apply(compiler)\n }\n}\n","import type {EMPSHARERuntimeOptions} from './types'\nexport function getRuntimeLib(host: EMPSHARERuntimeOptions['frameworkLib'], mode: string, entry = 'runtime') {\n if (typeof host === 'string') {\n if (entry === 'runtime') {\n return `${host}/runtime${mode === 'development' ? '.development' : ''}.umd.js`\n } else {\n return `${host}/${entry}.${mode}.umd.js`\n }\n } else if (typeof host === 'object') {\n if (mode === 'development') return host.dev\n else return host.prod\n }\n return ''\n}\n","import type {GlobalStore} from '@empjs/cli'\nimport {deepAssign} from 'src/helper'\nimport {shareGlobalName} from 'src/helper/config'\nimport {ModuleFederationPlugin} from 'src/helper/rspack'\nimport {EmpShareRemoteLibPlugin} from './plugin'\nimport type {\n EMPPluginShareType,\n ExternalsItemType,\n ModuleFederationPluginOptions,\n frameworkOptions,\n runtimeLibType,\n} from './types'\nimport {getRuntimeLib} from './utils'\nconst exp = /^([0-9a-zA-Z_\\s]+)@(.*)/\nexport class EmpShare {\n private op: EMPPluginShareType\n private store: GlobalStore\n /**\n * 注入资源\n */\n private injectHtml: any[] = []\n /**\n * 兼容 shareLib\n */\n private externalsLib: ExternalsItemType[] = []\n constructor(op: EMPPluginShareType, store: GlobalStore) {\n this.op = op || {}\n this.store = store\n }\n setup() {\n this.resetRuntime()\n this.resetFramework()\n this.setMfName() //设置 mfName 默认为 uniqueName\n this.setMF() // 设置 MF 配置\n this.injectGlobalVal() // 插入全局变量 方便emp外的项目调用\n this.injectFramework() // 插入ui框架库\n this.setShareLib() //兼容 emp Sharelib的共享模型设置\n this.setRuntimeLib() // 设置 MF SDK\n this.injectToHtml() //触发插入动作\n this.setExternal() // 设置 external 降低包体\n }\n private injectToHtml() {\n const {store, injectHtml} = this\n if (injectHtml.length > 0) {\n store.injectTags(injectHtml, 'EMPShare')\n }\n }\n private injectFramework() {\n if (this.fk.libs.length > 0) {\n return this.injectFkLibs(this.fk.libs)\n }\n if (!this.op.empRuntime || !this.fk.lib) return\n const {store, injectHtml} = this\n if (this.fk.lib) {\n const url = getRuntimeLib(this.fk.lib, store.mode, this.fk.entry)\n injectHtml.push({\n attributes: {\n src: url,\n },\n tagName: 'script',\n })\n }\n }\n private injectFkLibs(libs: string[]) {\n libs.map(url => {\n if (url.endsWith('.css')) {\n return this.injectHtml.push({\n attributes: {\n href: url,\n rel: 'stylesheet',\n },\n tagName: 'link',\n })\n }\n this.injectHtml.push({\n attributes: {\n src: url,\n },\n tagName: 'script',\n })\n })\n }\n private injectGlobalVal() {\n if (!this.op.empRuntime) return\n const {empRuntime} = this.op\n const {injectHtml} = this\n const frameworkGlobal = this.fk.global || (empRuntime.shareLib ? 'window' : '')\n const injectGlobalValToHtml = empRuntime.injectGlobalValToHtml === false || !this.rt.lib ? false : true\n // 插入全局引用变量 让 empRuntime 可以提前实例化 不需要在页面重复实例化\n if (injectGlobalValToHtml) {\n const injectData: any = {frameworkLib: frameworkGlobal, runtimeLib: this.rt.global}\n if (this.fk.name && this.fk.name !== 'none') injectData.framework = this.fk.name\n injectHtml.push({\n // type: 'js',\n tagName: 'script',\n innerHTML: `EMPShareGlobalVal=${JSON.stringify(injectData)}`,\n })\n }\n }\n public fk!: Required<frameworkOptions>\n private resetFramework() {\n if (!this.op.empRuntime) return\n const {framework, frameworkGlobal, frameworkLib} = this.op.empRuntime\n //\n this.fk = {\n name: 'none',\n version: 0,\n entry: '',\n global: frameworkGlobal || '',\n lib: frameworkLib || '',\n libs: [],\n }\n //\n if (typeof framework === 'string') {\n this.fk.name = framework as any\n }\n // TODO 通用 CDN 的适配方案\n else if (typeof framework === 'object' && Object.keys(framework).length > 0) {\n // 默认 框架名 为入口\n framework.entry = framework.entry ? framework.entry : framework.name\n this.fk = deepAssign(this.fk, framework)\n }\n }\n public rt!: Required<runtimeLibType>\n private resetRuntime() {\n const {empRuntime} = this.op\n if (!empRuntime) return\n const global = empRuntime.runtimeGlobal || shareGlobalName\n const lib = empRuntime.runtimeLib ? empRuntime.runtimeLib : empRuntime.runtime?.lib ? empRuntime.runtime.lib : ''\n this.rt = {\n lib,\n global,\n }\n }\n private setExternal() {\n if (!this.op.empRuntime) return\n const {store, externalsLib} = this\n const {empRuntime} = this.op\n const {shareLib} = empRuntime\n //\n const externalRuntime = this.rt.lib\n ? {\n '@module-federation/runtime': `MFRuntime`,\n '@module-federation/sdk': `MFSDK`,\n }\n : {}\n const externals = {}\n for (const [key, value] of Object.entries(externalRuntime)) {\n externals[key] = `${this.rt.global}.${value}`\n }\n /**\n * TODO\n * 框架相关内容需要移除 share 由外部简化配置实现\n */\n if (this.fk.name === 'react' && !shareLib && this.fk.global) {\n const version = this.fk.version\n const externalReact = {\n react: `React`,\n 'react-dom': `ReactDOM`,\n }\n if (this.fk.entry === 'reactRouter') {\n externalReact['react-router-dom'] = 'ReactRouterDOM'\n }\n for (const [key, value] of Object.entries(externalReact)) {\n externals[key] = `${this.fk.global}.${value}`\n }\n if ([17, 18, 19].includes(version)) {\n externals['react-dom/client'] = this.fk.global\n externals['react/jsx-runtime'] = this.fk.global\n externals['react/jsx-dev-runtime'] = this.fk.global\n }\n }\n if (shareLib) {\n externalsLib.map(v => {\n if (v.type === 'js' && v.module && v.global) {\n externals[v.module] = `${this.fk.global}.${v.global}`\n }\n })\n }\n if (empRuntime.setExternals) empRuntime.setExternals(externals, this.fk.global, this.rt.global)\n //\n // console.log('externals in plugin', externals)\n store.chain.merge({externals})\n }\n private setRuntimeLib() {\n if (!this.op.empRuntime) return\n\n const {shareLib} = this.op.empRuntime\n const {store, injectHtml} = this\n const {empRuntime} = this.op\n if (!this.rt.lib) {\n // 内置 this.rt.lib\n store.chain.plugin('plugin-emp-share-framework').use(EmpShareRemoteLibPlugin, [empRuntime])\n }\n // 统一封装到 frameworkLib\n else if (this.rt.lib === 'useFrameworkLib' && !shareLib) {\n } else {\n // 插入 runtime\n injectHtml.push({tagName: 'script', pos: 'head', attributes: {src: this.rt.lib}})\n }\n }\n private setMfName() {\n if (this.op.name) {\n this.op.name = this.store.encodeVarName(this.op.name)\n if (this.op.name !== this.store.empConfig.output.uniqueName) {\n this.store.chain.output.set('uniqueName', this.op.name)\n }\n } else {\n this.op.name = this.store.empConfig.output.uniqueName\n }\n }\n private setMF() {\n const o = this.op\n const {store} = this\n if (o.name) {\n const op = store.deepAssign<ModuleFederationPluginOptions & {empRuntime: any}>(\n {\n filename: 'emp.js',\n manifest: false,\n dts: false,\n dev: {\n disableDynamicRemoteTypeHints: true,\n },\n },\n o,\n )\n if (op.empRuntime) {\n delete op.empRuntime\n }\n store.chain.plugin('plugin-emp-share').use(ModuleFederationPlugin, [op])\n }\n }\n private setShareLib() {\n if (!this.op.empRuntime) return\n const {shareLib} = this.op.empRuntime\n const {externalsLib, injectHtml} = this\n if (shareLib && typeof shareLib === 'object') {\n for (const [k, v] of Object.entries(shareLib)) {\n let externalsItem: ExternalsItemType = {}\n externalsItem.module = k\n //增加下划线 支持lodash 等特殊符号的问题 如 _@http\n\n if (typeof v === 'string') {\n const cb: any = v.match(exp) || []\n if (cb.length > 0) {\n externalsItem.global = cb[1]\n externalsItem.entry = cb[2]\n externalsItem.type = 'js'\n externalsLib.push(externalsItem)\n externalsItem = {}\n } else {\n externalsItem.global = ''\n externalsItem.entry = v\n externalsItem.type = 'js'\n externalsLib.push(externalsItem)\n externalsItem = {}\n }\n } else if (Array.isArray(v)) {\n v.map(vo => {\n if (!vo) return\n const isCSS = vo.split('?')[0].endsWith('.css')\n if (isCSS) {\n externalsItem.entry = vo\n externalsItem.type = 'css'\n } else {\n const cb: any = vo.match(exp) || []\n if (cb.length > 0) {\n externalsItem.global = cb[1]\n externalsItem.entry = cb[2]\n externalsItem.type = 'js'\n } else {\n externalsItem.global = ''\n externalsItem.entry = vo\n externalsItem.type = 'js'\n }\n }\n externalsLib.push(externalsItem)\n externalsItem = {}\n })\n } else if (typeof v === 'object' && v.entry) {\n externalsItem.entry = v.entry\n externalsItem.global = v.global\n externalsItem.type = v.type\n externalsLib.push(externalsItem)\n externalsItem = {}\n }\n }\n // console.log(externalsLib)\n externalsLib.map(v => {\n if (v.type === 'js') {\n injectHtml.push({\n attributes: {\n src: v.entry,\n },\n tagName: 'script',\n })\n } else if (v.type === 'css') {\n injectHtml.push({\n attributes: {\n href: v.entry,\n rel: 'stylesheet',\n },\n tagName: 'link',\n })\n }\n })\n }\n }\n}\n","export const externalReact = (o: any, globalVal: string) => {\n o = Object.assign(o, {\n react: `${globalVal}.React`,\n 'react-dom': `${globalVal}.ReactDOM`,\n 'react-dom/client': globalVal,\n 'react/jsx-runtime': globalVal,\n 'react/jsx-dev-runtime': globalVal,\n 'react-router-dom': `${globalVal}.ReactRouterDOM`,\n })\n return o\n}\n","export const externalVue = (o: any, globalVal: string) => {\n o = Object.assign(o, {\n vue: `${globalVal}.Vue`,\n 'vue-router': `${globalVal}.VueRouter`,\n })\n return o\n}\n","import type {GlobalStore} from '@empjs/cli'\nimport {EmpShare} from './share'\nimport type {EMPPluginShareType} from './types'\n//\nexport * from 'src/framework/react/config'\nexport * from 'src/framework/vue/config'\n//\nexport const pluginRspackEmpShare = (o: EMPPluginShareType = {}) => {\n return {\n name: '@empjs/share',\n async rsConfig(store: GlobalStore) {\n //\n if (o.manifest === true) {\n o.manifest = {\n fileName: 'emp.json',\n }\n } else if (typeof o.manifest === 'object') {\n o.manifest = store.deepAssign({fileName: 'emp.json'}, o.manifest)\n }\n const empShare = new EmpShare(o, store)\n empShare.setup()\n },\n }\n}\nexport default pluginRspackEmpShare\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,kBAAAC,EAAA,gBAAAC,EAAA,yBAAAC,IAAA,eAAAC,EAAAN,GCAO,IAAMO,EAAcC,GAAoB,wBAAwBA,CAAO,GAEvE,SAASC,EAAcC,KAAgBC,EAAiB,CAC7D,QAAWC,KAAUD,EACnB,QAAWE,KAAKD,EAAQ,CACtB,IAAME,EAAKF,EAAOC,CAAC,EACjBE,EAAKL,EAAOG,CAAC,EACf,GAAI,OAAOC,CAAE,GAAKA,GAAM,OAAOC,CAAE,IAAMA,EAAI,CACzCL,EAAOG,CAAC,EAAIJ,EAAWM,EAAID,CAAE,EAC7B,QACF,CACAJ,EAAOG,CAAC,EAAID,EAAOC,CAAC,CACtB,CAEF,OAAOH,CACT,CAMO,IAAMM,EAAQ,GACRC,EAAMD,EAAQ,QAAQ,IAAI,KAAK,QAAS,aAAa,EAAI,IAAM,CAAC,ECtBtE,IAAME,EAAkB,oBCA/B,IAAAC,EAAqC,8CCGrC,IAAMC,EAAuBC,GAAO,CAClC,IAAMC,EAAU,CAAC,WAAWD,CAAG,GAAG,EAAE,KAAK;AAAA,CAAI,EAC7C,OAAOE,EAAWD,CAAO,CAC3B,EAEaE,EAAN,KAA8B,CACnC,QACA,YAAYC,EAA4B,CACtC,KAAK,QAAUA,CACjB,CACA,MAAMC,EAAoB,CACxB,GAAM,CAAC,QAAAC,CAAO,EAAID,EACZE,EAAQR,EAAqB,sBAAsB,EACzD,IAAIO,EAAQ,YAAYD,EAAS,QA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GAAK,CAChBA,EAAE,OAAS,KACbrB,EAAW,KAAK,CACd,WAAY,CACV,IAAKqB,EAAE,KACT,EACA,QAAS,QACX,CAAC,EACQA,EAAE,OAAS,OACpBrB,EAAW,KAAK,CACd,WAAY,CACV,KAAMqB,EAAE,MACR,IAAK,YACP,EACA,QAAS,MACX,CAAC,CAEL,CAAC,CACH,CACF,CACF,ECpTO,IAAMO,EAAgB,CAACC,EAAQC,KACpCD,EAAI,OAAO,OAAOA,EAAG,CACnB,MAAO,GAAGC,CAAS,SACnB,YAAa,GAAGA,CAAS,YACzB,mBAAoBA,EACpB,oBAAqBA,EACrB,wBAAyBA,EACzB,mBAAoB,GAAGA,CAAS,iBAClC,CAAC,EACMD,GCTF,IAAME,EAAc,CAACC,EAAQC,KAClCD,EAAI,OAAO,OAAOA,EAAG,CACnB,IAAK,GAAGC,CAAS,OACjB,aAAc,GAAGA,CAAS,YAC5B,CAAC,EACMD,GCEF,IAAME,EAAuB,CAACC,EAAwB,CAAC,KACrD,CACL,KAAM,eACN,MAAM,SAASC,EAAoB,CAE7BD,EAAE,WAAa,GACjBA,EAAE,SAAW,CACX,SAAU,UACZ,EACS,OAAOA,EAAE,UAAa,WAC/BA,EAAE,SAAWC,EAAM,WAAW,CAAC,SAAU,UAAU,EAAGD,EAAE,QAAQ,GAEjD,IAAIE,EAASF,EAAGC,CAAK,EAC7B,MAAM,CACjB,CACF,GAEKE,EAAQJ,ETvBf,IAAOK,EAAQC","names":["src_exports","__export","src_default","externalReact","externalVue","pluginRspackEmpShare","__toCommonJS","importJsVm","content","deepAssign","target","sources","source","k","vs","vt","isDev","log","shareGlobalName","import_rspack","getShareRuntimeEntry","url","content","importJsVm","EmpShareRemoteLibPlugin","op","compiler","webpack","entry","getRuntimeLib","host","mode","entry","exp","EmpShare","op","store","injectHtml","url","getRuntimeLib","libs","empRuntime","frameworkGlobal","injectData","framework","frameworkLib","deepAssign","global","shareGlobalName","lib","externalsLib","shareLib","externalRuntime","externals","key","value","version","externalReact","v","EmpShareRemoteLibPlugin","o","k","externalsItem","cb","vo","externalReact","o","globalVal","externalVue","o","globalVal","pluginRspackEmpShare","o","store","EmpShare","rspack_default","src_default","rspack_default"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/helper/index.ts","../src/helper/config.ts","../src/helper/rspack.ts","../src/plugins/rspack/plugin.ts","../src/plugins/rspack/utils.ts","../src/plugins/rspack/share.ts","../src/framework/react/config.ts","../src/framework/vue/config.ts","../src/plugins/rspack/index.ts"],"sourcesContent":["import {default as pluginRspackEmpShare} from 'src/plugins/rspack'\nexport default pluginRspackEmpShare\nexport * from 'src/plugins/rspack'\n","export const importJsVm = (content: string) => `data:text/javascript,${content}`\n\nexport function deepAssign<T>(target: any, ...sources: any): T {\n for (const source of sources) {\n for (const k in source) {\n const vs = source[k],\n vt = target[k]\n if (Object(vs) == vs && Object(vt) === vt) {\n target[k] = deepAssign(vt, vs)\n continue\n }\n target[k] = source[k]\n }\n }\n return target\n}\n\nexport const checkVersion = (version: string) => (version ? Number(version.split('.')[0]) : 0)\nexport const isPromise = (p: any) => p && Object.prototype.toString.call(p) === '[object Promise]'\n\n//\nexport const isDev = process.env.EMPSHARE_ENV === 'dev'\nexport const log = isDev ? console.log.bind(console, '[EMP Share]') : () => {}\n","export const shareGlobalName = 'EMP_SHARE_RUNTIME'\n","export {ModuleFederationPlugin} from '@module-federation/enhanced/rspack'\n","import type {Compiler} from '@rspack/core'\nimport {importJsVm} from 'src/helper'\nimport type {EMPSHARERuntimeOptions} from './types'\n\nconst getShareRuntimeEntry = url => {\n const content = [`import '${url}'`].join('\\n')\n return importJsVm(content)\n}\n// 当没有设置 runtimeLib 时候需要内置\nexport class EmpShareRemoteLibPlugin {\n options: EMPSHARERuntimeOptions\n constructor(op: EMPSHARERuntimeOptions) {\n this.options = op\n }\n apply(compiler: Compiler) {\n const {webpack} = compiler\n const entry = getShareRuntimeEntry('@empjs/share/library')\n new webpack.EntryPlugin(compiler.context, entry, {\n name: undefined,\n }).apply(compiler)\n }\n}\n","import type {EMPSHARERuntimeOptions} from './types'\nexport function getRuntimeLib(host: EMPSHARERuntimeOptions['frameworkLib'], mode: string, entry = 'runtime') {\n if (typeof host === 'string') {\n if (entry === 'runtime') {\n return `${host}/runtime${mode === 'development' ? '.development' : ''}.umd.js`\n } else {\n return `${host}/${entry}.${mode}.umd.js`\n }\n } else if (typeof host === 'object') {\n if (mode === 'development') return host.dev\n else return host.prod\n }\n return ''\n}\n","import type {GlobalStore} from '@empjs/cli'\nimport {deepAssign} from 'src/helper'\nimport {shareGlobalName} from 'src/helper/config'\nimport {ModuleFederationPlugin} from 'src/helper/rspack'\nimport {EmpShareRemoteLibPlugin} from './plugin'\nimport type {\n EMPPluginShareType,\n ExternalsItemType,\n frameworkOptions,\n ModuleFederationPluginOptions,\n runtimeLibType,\n} from './types'\nimport {getRuntimeLib} from './utils'\n\nconst exp = /^([0-9a-zA-Z_\\s]+)@(.*)/\nexport class EmpShare {\n private op: EMPPluginShareType\n private store: GlobalStore\n /**\n * 注入资源\n */\n private injectHtml: any[] = []\n /**\n * 兼容 shareLib\n */\n private externalsLib: ExternalsItemType[] = []\n constructor(op: EMPPluginShareType, store: GlobalStore) {\n this.op = op || {}\n this.store = store\n }\n setup() {\n this.resetRuntime()\n this.resetFramework()\n this.setMfName() //设置 mfName 默认为 uniqueName\n this.setMF() // 设置 MF 配置\n this.injectGlobalVal() // 插入全局变量 方便emp外的项目调用\n this.injectFramework() // 插入ui框架库\n this.setShareLib() //兼容 emp Sharelib的共享模型设置\n this.setRuntimeLib() // 设置 MF SDK\n this.injectToHtml() //触发插入动作\n this.setExternal() // 设置 external 降低包体\n }\n private injectToHtml() {\n const {store, injectHtml} = this\n if (injectHtml.length > 0) {\n store.injectTags(injectHtml, 'EMPShare')\n }\n }\n private injectFramework() {\n if (this.fk && this.fk.libs.length > 0) {\n return this.injectFkLibs(this.fk.libs)\n }\n if (!this.op.empRuntime || !this.fk.lib) return\n const {store, injectHtml} = this\n if (this.fk.lib) {\n const url = getRuntimeLib(this.fk.lib, store.mode, this.fk.entry)\n injectHtml.push({\n attributes: {\n src: url,\n },\n tagName: 'script',\n })\n }\n }\n private injectFkLibs(libs: string[]) {\n libs.map(url => {\n if (url.endsWith('.css')) {\n return this.injectHtml.push({\n attributes: {\n href: url,\n rel: 'stylesheet',\n },\n tagName: 'link',\n })\n }\n this.injectHtml.push({\n attributes: {\n src: url,\n },\n tagName: 'script',\n })\n })\n }\n private injectGlobalVal() {\n if (!this.op.empRuntime) return\n const {empRuntime} = this.op\n const {injectHtml} = this\n const frameworkGlobal = this.fk.global || (empRuntime.shareLib ? 'window' : '')\n const injectGlobalValToHtml = empRuntime.injectGlobalValToHtml === false || !this.rt.lib ? false : true\n // 插入全局引用变量 让 empRuntime 可以提前实例化 不需要在页面重复实例化\n if (injectGlobalValToHtml) {\n const injectData: any = {frameworkLib: frameworkGlobal, runtimeLib: this.rt.global}\n if (this.fk.name && this.fk.name !== 'none') injectData.framework = this.fk.name\n injectHtml.push({\n // type: 'js',\n tagName: 'script',\n innerHTML: `EMPShareGlobalVal=${JSON.stringify(injectData)}`,\n })\n }\n }\n public fk!: Required<frameworkOptions>\n private resetFramework() {\n if (!this.op.empRuntime) return\n const {framework, frameworkGlobal, frameworkLib} = this.op.empRuntime\n //\n this.fk = {\n name: 'none',\n version: 0,\n entry: '',\n global: frameworkGlobal || '',\n lib: frameworkLib || '',\n libs: [],\n }\n //\n if (typeof framework === 'string') {\n this.fk.name = framework as any\n }\n // TODO 通用 CDN 的适配方案\n else if (typeof framework === 'object' && Object.keys(framework).length > 0) {\n // 默认 框架名 为入口\n framework.entry = framework.entry ? framework.entry : framework.name\n this.fk = deepAssign(this.fk, framework)\n }\n }\n public rt!: Required<runtimeLibType>\n private resetRuntime() {\n const {empRuntime} = this.op\n if (!empRuntime) return\n const global = empRuntime.runtimeGlobal || shareGlobalName\n const lib = empRuntime.runtimeLib ? empRuntime.runtimeLib : empRuntime.runtime?.lib ? empRuntime.runtime.lib : ''\n this.rt = {\n lib,\n global,\n }\n }\n private setExternal() {\n if (!this.op.empRuntime) return\n const {store, externalsLib} = this\n const {empRuntime} = this.op\n const {shareLib} = empRuntime\n //\n const externalRuntime = this.rt.lib\n ? {\n '@module-federation/runtime': `MFRuntime`,\n '@module-federation/sdk': `MFSDK`,\n }\n : {}\n const externals = {}\n for (const [key, value] of Object.entries(externalRuntime)) {\n externals[key] = `${this.rt.global}.${value}`\n }\n /**\n * TODO\n * 框架相关内容需要移除 share 由外部简化配置实现\n */\n if (this.fk.name === 'react' && !shareLib && this.fk.global) {\n const version = this.fk.version\n const externalReact = {\n react: `React`,\n 'react-dom': `ReactDOM`,\n }\n if (this.fk.entry === 'reactRouter') {\n externalReact['react-router-dom'] = 'ReactRouterDOM'\n }\n for (const [key, value] of Object.entries(externalReact)) {\n externals[key] = `${this.fk.global}.${value}`\n }\n if ([17, 18, 19].includes(version)) {\n externals['react-dom/client'] = this.fk.global\n externals['react/jsx-runtime'] = this.fk.global\n externals['react/jsx-dev-runtime'] = this.fk.global\n }\n }\n if (shareLib) {\n externalsLib.map(v => {\n if (v.type === 'js' && v.module && v.global) {\n externals[v.module] = `${this.fk.global}.${v.global}`\n }\n })\n }\n if (empRuntime.setExternals) empRuntime.setExternals(externals, this.fk.global, this.rt.global)\n //\n // console.log('externals in plugin', externals)\n store.chain.merge({externals})\n }\n private setRuntimeLib() {\n if (!this.op.empRuntime) return\n\n const {shareLib} = this.op.empRuntime\n const {store, injectHtml} = this\n const {empRuntime} = this.op\n if (!this.rt.lib) {\n // 内置 this.rt.lib\n store.chain.plugin('plugin-emp-share-framework').use(EmpShareRemoteLibPlugin, [empRuntime])\n }\n // 统一封装到 frameworkLib\n else if (this.rt.lib === 'useFrameworkLib' && !shareLib) {\n } else {\n // 插入 runtime\n injectHtml.push({tagName: 'script', pos: 'head', attributes: {src: this.rt.lib}})\n }\n }\n private setMfName() {\n if (this.op.name) {\n this.op.name = this.store.encodeVarName(this.op.name)\n if (this.op.name !== this.store.empConfig.output.uniqueName) {\n this.store.chain.output.set('uniqueName', this.op.name)\n }\n } else {\n this.op.name = this.store.empConfig.output.uniqueName\n }\n }\n private setMF() {\n const o = this.op\n const {store} = this\n if (o.name) {\n const op = store.deepAssign<ModuleFederationPluginOptions & {empRuntime: any}>(\n {\n filename: 'emp.js',\n manifest: false,\n dts: false,\n dev: {\n disableDynamicRemoteTypeHints: true,\n },\n },\n o,\n )\n //\n if (o.dev === false) op.dev = false\n //\n if (op.empRuntime) {\n delete op.empRuntime\n }\n store.chain.plugin('plugin-emp-share').use(ModuleFederationPlugin, [op])\n }\n }\n private setShareLib() {\n if (!this.op.empRuntime) return\n const {shareLib} = this.op.empRuntime\n const {externalsLib, injectHtml} = this\n if (shareLib && typeof shareLib === 'object') {\n for (const [k, v] of Object.entries(shareLib)) {\n let externalsItem: ExternalsItemType = {}\n externalsItem.module = k\n //增加下划线 支持lodash 等特殊符号的问题 如 _@http\n\n if (typeof v === 'string') {\n const cb: any = v.match(exp) || []\n if (cb.length > 0) {\n externalsItem.global = cb[1]\n externalsItem.entry = cb[2]\n externalsItem.type = 'js'\n externalsLib.push(externalsItem)\n externalsItem = {}\n } else {\n externalsItem.global = ''\n externalsItem.entry = v\n externalsItem.type = 'js'\n externalsLib.push(externalsItem)\n externalsItem = {}\n }\n } else if (Array.isArray(v)) {\n v.map(vo => {\n if (!vo) return\n const isCSS = vo.split('?')[0].endsWith('.css')\n if (isCSS) {\n externalsItem.entry = vo\n externalsItem.type = 'css'\n } else {\n const cb: any = vo.match(exp) || []\n if (cb.length > 0) {\n externalsItem.global = cb[1]\n externalsItem.entry = cb[2]\n externalsItem.type = 'js'\n } else {\n externalsItem.global = ''\n externalsItem.entry = vo\n externalsItem.type = 'js'\n }\n }\n externalsLib.push(externalsItem)\n externalsItem = {}\n })\n } else if (typeof v === 'object' && v.entry) {\n externalsItem.entry = v.entry\n externalsItem.global = v.global\n externalsItem.type = v.type\n externalsLib.push(externalsItem)\n externalsItem = {}\n }\n }\n // console.log(externalsLib)\n externalsLib.map(v => {\n if (v.type === 'js') {\n injectHtml.push({\n attributes: {\n src: v.entry,\n },\n tagName: 'script',\n })\n } else if (v.type === 'css') {\n injectHtml.push({\n attributes: {\n href: v.entry,\n rel: 'stylesheet',\n },\n tagName: 'link',\n })\n }\n })\n }\n }\n}\n","export const externalReact = (o: any, globalVal: string) => {\n o = Object.assign(o, {\n react: `${globalVal}.React`,\n 'react-dom': `${globalVal}.ReactDOM`,\n 'react-dom/client': globalVal,\n 'react/jsx-runtime': globalVal,\n 'react/jsx-dev-runtime': globalVal,\n 'react-router-dom': `${globalVal}.ReactRouterDOM`,\n })\n return o\n}\n","export const externalVue = (o: any, globalVal: string) => {\n o = Object.assign(o, {\n vue: `${globalVal}.Vue`,\n 'vue-router': `${globalVal}.VueRouter`,\n })\n return o\n}\n","import type {GlobalStore} from '@empjs/cli'\nimport {EmpShare} from './share'\nimport type {EMPPluginShareType} from './types'\n\n//\nexport * from 'src/framework/react/config'\nexport * from 'src/framework/vue/config'\n//\nexport const pluginRspackEmpShare = (o: EMPPluginShareType = {}) => {\n return {\n name: '@empjs/share',\n async rsConfig(store: GlobalStore) {\n //\n if (o.manifest === true) {\n o.manifest = {\n fileName: 'emp.json',\n }\n } else if (typeof o.manifest === 'object') {\n o.manifest = store.deepAssign({fileName: 'emp.json'}, o.manifest)\n }\n const empShare = new EmpShare(o, store)\n empShare.setup()\n },\n }\n}\nexport default pluginRspackEmpShare\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,kBAAAC,EAAA,gBAAAC,EAAA,yBAAAC,IAAA,eAAAC,EAAAN,GCAO,IAAMO,EAAcC,GAAoB,wBAAwBA,CAAO,GAEvE,SAASC,EAAcC,KAAgBC,EAAiB,CAC7D,QAAWC,KAAUD,EACnB,QAAWE,KAAKD,EAAQ,CACtB,IAAME,EAAKF,EAAOC,CAAC,EACjBE,EAAKL,EAAOG,CAA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,CAAS,OACjB,aAAc,GAAGA,CAAS,YAC5B,CAAC,EACMD,GCGF,IAAME,EAAuB,CAACC,EAAwB,CAAC,KACrD,CACL,KAAM,eACN,MAAM,SAASC,EAAoB,CAE7BD,EAAE,WAAa,GACjBA,EAAE,SAAW,CACX,SAAU,UACZ,EACS,OAAOA,EAAE,UAAa,WAC/BA,EAAE,SAAWC,EAAM,WAAW,CAAC,SAAU,UAAU,EAAGD,EAAE,QAAQ,GAEjD,IAAIE,EAASF,EAAGC,CAAK,EAC7B,MAAM,CACjB,CACF,GAEKE,EAAQJ,ETxBf,IAAOK,EAAQC","names":["src_exports","__export","src_default","externalReact","externalVue","pluginRspackEmpShare","__toCommonJS","importJsVm","content","deepAssign","target","sources","source","k","vs","vt","isDev","log","shareGlobalName","import_rspack","getShareRuntimeEntry","url","content","importJsVm","EmpShareRemoteLibPlugin","op","compiler","webpack","entry","getRuntimeLib","host","mode","entry","exp","EmpShare","op","store","injectHtml","url","getRuntimeLib","libs","empRuntime","frameworkGlobal","injectData","framework","frameworkLib","deepAssign","global","shareGlobalName","lib","externalsLib","shareLib","externalRuntime","externals","key","value","version","externalReact","v","EmpShareRemoteLibPlugin","o","k","externalsItem","cb","vo","externalReact","o","globalVal","externalVue","o","globalVal","pluginRspackEmpShare","o","store","EmpShare","rspack_default","src_default","rspack_default"]}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var f=s=>`data:text/javascript,${s}`;function u(s,...e){for(let t of e)for(let r in t){let a=t[r],n=s[r];if(Object(a)==a&&Object(n)===n){s[r]=u(n,a);continue}s[r]=t[r]}return s}var
|
|
2
|
-
`);return f(e)},l=class{options;constructor(e){this.options=e}apply(e){let{webpack:t}=e,r=
|
|
1
|
+
var f=s=>`data:text/javascript,${s}`;function u(s,...e){for(let t of e)for(let r in t){let a=t[r],n=s[r];if(Object(a)==a&&Object(n)===n){s[r]=u(n,a);continue}s[r]=t[r]}return s}var k=!1,E=k?console.log.bind(console,"[EMP Share]"):()=>{};var h="EMP_SHARE_RUNTIME";import{ModuleFederationPlugin as b}from"@module-federation/enhanced/rspack";var R=s=>{let e=[`import '${s}'`].join(`
|
|
2
|
+
`);return f(e)},l=class{options;constructor(e){this.options=e}apply(e){let{webpack:t}=e,r=R("@empjs/share/library");new t.EntryPlugin(e.context,r,{name:void 0}).apply(e)}};function y(s,e,t="runtime"){return typeof s=="string"?t==="runtime"?`${s}/runtime${e==="development"?".development":""}.umd.js`:`${s}/${t}.${e}.umd.js`:typeof s=="object"?e==="development"?s.dev:s.prod:""}var g=/^([0-9a-zA-Z_\s]+)@(.*)/,c=class{op;store;injectHtml=[];externalsLib=[];constructor(e,t){this.op=e||{},this.store=t}setup(){this.resetRuntime(),this.resetFramework(),this.setMfName(),this.setMF(),this.injectGlobalVal(),this.injectFramework(),this.setShareLib(),this.setRuntimeLib(),this.injectToHtml(),this.setExternal()}injectToHtml(){let{store:e,injectHtml:t}=this;t.length>0&&e.injectTags(t,"EMPShare")}injectFramework(){if(this.fk&&this.fk.libs.length>0)return this.injectFkLibs(this.fk.libs);if(!this.op.empRuntime||!this.fk.lib)return;let{store:e,injectHtml:t}=this;if(this.fk.lib){let r=y(this.fk.lib,e.mode,this.fk.entry);t.push({attributes:{src:r},tagName:"script"})}}injectFkLibs(e){e.map(t=>{if(t.endsWith(".css"))return this.injectHtml.push({attributes:{href:t,rel:"stylesheet"},tagName:"link"});this.injectHtml.push({attributes:{src:t},tagName:"script"})})}injectGlobalVal(){if(!this.op.empRuntime)return;let{empRuntime:e}=this.op,{injectHtml:t}=this,r=this.fk.global||(e.shareLib?"window":"");if(!(e.injectGlobalValToHtml===!1||!this.rt.lib)){let n={frameworkLib:r,runtimeLib:this.rt.global};this.fk.name&&this.fk.name!=="none"&&(n.framework=this.fk.name),t.push({tagName:"script",innerHTML:`EMPShareGlobalVal=${JSON.stringify(n)}`})}}fk;resetFramework(){if(!this.op.empRuntime)return;let{framework:e,frameworkGlobal:t,frameworkLib:r}=this.op.empRuntime;this.fk={name:"none",version:0,entry:"",global:t||"",lib:r||"",libs:[]},typeof e=="string"?this.fk.name=e:typeof e=="object"&&Object.keys(e).length>0&&(e.entry=e.entry?e.entry:e.name,this.fk=u(this.fk,e))}rt;resetRuntime(){let{empRuntime:e}=this.op;if(!e)return;let t=e.runtimeGlobal||h,r=e.runtimeLib?e.runtimeLib:e.runtime?.lib?e.runtime.lib:"";this.rt={lib:r,global:t}}setExternal(){if(!this.op.empRuntime)return;let{store:e,externalsLib:t}=this,{empRuntime:r}=this.op,{shareLib:a}=r,n=this.rt.lib?{"@module-federation/runtime":"MFRuntime","@module-federation/sdk":"MFSDK"}:{},i={};for(let[o,m]of Object.entries(n))i[o]=`${this.rt.global}.${m}`;if(this.fk.name==="react"&&!a&&this.fk.global){let o=this.fk.version,m={react:"React","react-dom":"ReactDOM"};this.fk.entry==="reactRouter"&&(m["react-router-dom"]="ReactRouterDOM");for(let[p,d]of Object.entries(m))i[p]=`${this.fk.global}.${d}`;[17,18,19].includes(o)&&(i["react-dom/client"]=this.fk.global,i["react/jsx-runtime"]=this.fk.global,i["react/jsx-dev-runtime"]=this.fk.global)}a&&t.map(o=>{o.type==="js"&&o.module&&o.global&&(i[o.module]=`${this.fk.global}.${o.global}`)}),r.setExternals&&r.setExternals(i,this.fk.global,this.rt.global),e.chain.merge({externals:i})}setRuntimeLib(){if(!this.op.empRuntime)return;let{shareLib:e}=this.op.empRuntime,{store:t,injectHtml:r}=this,{empRuntime:a}=this.op;this.rt.lib?this.rt.lib==="useFrameworkLib"&&!e||r.push({tagName:"script",pos:"head",attributes:{src:this.rt.lib}}):t.chain.plugin("plugin-emp-share-framework").use(l,[a])}setMfName(){this.op.name?(this.op.name=this.store.encodeVarName(this.op.name),this.op.name!==this.store.empConfig.output.uniqueName&&this.store.chain.output.set("uniqueName",this.op.name)):this.op.name=this.store.empConfig.output.uniqueName}setMF(){let e=this.op,{store:t}=this;if(e.name){let r=t.deepAssign({filename:"emp.js",manifest:!1,dts:!1,dev:{disableDynamicRemoteTypeHints:!0}},e);e.dev===!1&&(r.dev=!1),r.empRuntime&&delete r.empRuntime,t.chain.plugin("plugin-emp-share").use(b,[r])}}setShareLib(){if(!this.op.empRuntime)return;let{shareLib:e}=this.op.empRuntime,{externalsLib:t,injectHtml:r}=this;if(e&&typeof e=="object"){for(let[a,n]of Object.entries(e)){let i={};if(i.module=a,typeof n=="string"){let o=n.match(g)||[];o.length>0?(i.global=o[1],i.entry=o[2],i.type="js",t.push(i),i={}):(i.global="",i.entry=n,i.type="js",t.push(i),i={})}else Array.isArray(n)?n.map(o=>{if(!o)return;if(o.split("?")[0].endsWith(".css"))i.entry=o,i.type="css";else{let p=o.match(g)||[];p.length>0?(i.global=p[1],i.entry=p[2],i.type="js"):(i.global="",i.entry=o,i.type="js")}t.push(i),i={}}):typeof n=="object"&&n.entry&&(i.entry=n.entry,i.global=n.global,i.type=n.type,t.push(i),i={})}t.map(a=>{a.type==="js"?r.push({attributes:{src:a.entry},tagName:"script"}):a.type==="css"&&r.push({attributes:{href:a.entry,rel:"stylesheet"},tagName:"link"})})}}};var A=(s,e)=>(s=Object.assign(s,{react:`${e}.React`,"react-dom":`${e}.ReactDOM`,"react-dom/client":e,"react/jsx-runtime":e,"react/jsx-dev-runtime":e,"react-router-dom":`${e}.ReactRouterDOM`}),s);var V=(s,e)=>(s=Object.assign(s,{vue:`${e}.Vue`,"vue-router":`${e}.VueRouter`}),s);var x=(s={})=>({name:"@empjs/share",async rsConfig(e){s.manifest===!0?s.manifest={fileName:"emp.json"}:typeof s.manifest=="object"&&(s.manifest=e.deepAssign({fileName:"emp.json"},s.manifest)),new c(s,e).setup()}}),j=x;var z=j;export{z as default,A as externalReact,V as externalVue,x as pluginRspackEmpShare};
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/helper/index.ts","../src/helper/config.ts","../src/helper/rspack.ts","../src/plugins/rspack/plugin.ts","../src/plugins/rspack/utils.ts","../src/plugins/rspack/share.ts","../src/framework/react/config.ts","../src/framework/vue/config.ts","../src/plugins/rspack/index.ts","../src/index.ts"],"sourcesContent":["export const importJsVm = (content: string) => `data:text/javascript,${content}`\n\nexport function deepAssign<T>(target: any, ...sources: any): T {\n for (const source of sources) {\n for (const k in source) {\n const vs = source[k],\n vt = target[k]\n if (Object(vs) == vs && Object(vt) === vt) {\n target[k] = deepAssign(vt, vs)\n continue\n }\n target[k] = source[k]\n }\n }\n return target\n}\n\nexport const checkVersion = (version: string) => (version ? Number(version.split('.')[0]) : 0)\nexport const isPromise = (p: any) => p && Object.prototype.toString.call(p) === '[object Promise]'\n\n//\nexport const isDev = process.env.EMPSHARE_ENV === 'dev'\nexport const log = isDev ? console.log.bind(console, '[EMP Share]') : () => {}\n","export const shareGlobalName = 'EMP_SHARE_RUNTIME'\n","export {ModuleFederationPlugin} from '@module-federation/enhanced/rspack'\n","import type {Compiler} from '@rspack/core'\nimport {importJsVm} from 'src/helper'\nimport type {EMPSHARERuntimeOptions} from './types'\nconst getShareRuntimeEntry = url => {\n const content = [`import '${url}'`].join('\\n')\n return importJsVm(content)\n}\n// 当没有设置 runtimeLib 时候需要内置\nexport class EmpShareRemoteLibPlugin {\n options: EMPSHARERuntimeOptions\n constructor(op: EMPSHARERuntimeOptions) {\n this.options = op\n }\n apply(compiler: Compiler) {\n const {webpack} = compiler\n const entry = getShareRuntimeEntry('@empjs/share/library')\n new webpack.EntryPlugin(compiler.context, entry, {\n name: undefined,\n }).apply(compiler)\n }\n}\n","import type {EMPSHARERuntimeOptions} from './types'\nexport function getRuntimeLib(host: EMPSHARERuntimeOptions['frameworkLib'], mode: string, entry = 'runtime') {\n if (typeof host === 'string') {\n if (entry === 'runtime') {\n return `${host}/runtime${mode === 'development' ? '.development' : ''}.umd.js`\n } else {\n return `${host}/${entry}.${mode}.umd.js`\n }\n } else if (typeof host === 'object') {\n if (mode === 'development') return host.dev\n else return host.prod\n }\n return ''\n}\n","import type {GlobalStore} from '@empjs/cli'\nimport {deepAssign} from 'src/helper'\nimport {shareGlobalName} from 'src/helper/config'\nimport {ModuleFederationPlugin} from 'src/helper/rspack'\nimport {EmpShareRemoteLibPlugin} from './plugin'\nimport type {\n EMPPluginShareType,\n ExternalsItemType,\n ModuleFederationPluginOptions,\n frameworkOptions,\n runtimeLibType,\n} from './types'\nimport {getRuntimeLib} from './utils'\nconst exp = /^([0-9a-zA-Z_\\s]+)@(.*)/\nexport class EmpShare {\n private op: EMPPluginShareType\n private store: GlobalStore\n /**\n * 注入资源\n */\n private injectHtml: any[] = []\n /**\n * 兼容 shareLib\n */\n private externalsLib: ExternalsItemType[] = []\n constructor(op: EMPPluginShareType, store: GlobalStore) {\n this.op = op || {}\n this.store = store\n }\n setup() {\n this.resetRuntime()\n this.resetFramework()\n this.setMfName() //设置 mfName 默认为 uniqueName\n this.setMF() // 设置 MF 配置\n this.injectGlobalVal() // 插入全局变量 方便emp外的项目调用\n this.injectFramework() // 插入ui框架库\n this.setShareLib() //兼容 emp Sharelib的共享模型设置\n this.setRuntimeLib() // 设置 MF SDK\n this.injectToHtml() //触发插入动作\n this.setExternal() // 设置 external 降低包体\n }\n private injectToHtml() {\n const {store, injectHtml} = this\n if (injectHtml.length > 0) {\n store.injectTags(injectHtml, 'EMPShare')\n }\n }\n private injectFramework() {\n if (this.fk.libs.length > 0) {\n return this.injectFkLibs(this.fk.libs)\n }\n if (!this.op.empRuntime || !this.fk.lib) return\n const {store, injectHtml} = this\n if (this.fk.lib) {\n const url = getRuntimeLib(this.fk.lib, store.mode, this.fk.entry)\n injectHtml.push({\n attributes: {\n src: url,\n },\n tagName: 'script',\n })\n }\n }\n private injectFkLibs(libs: string[]) {\n libs.map(url => {\n if (url.endsWith('.css')) {\n return this.injectHtml.push({\n attributes: {\n href: url,\n rel: 'stylesheet',\n },\n tagName: 'link',\n })\n }\n this.injectHtml.push({\n attributes: {\n src: url,\n },\n tagName: 'script',\n })\n })\n }\n private injectGlobalVal() {\n if (!this.op.empRuntime) return\n const {empRuntime} = this.op\n const {injectHtml} = this\n const frameworkGlobal = this.fk.global || (empRuntime.shareLib ? 'window' : '')\n const injectGlobalValToHtml = empRuntime.injectGlobalValToHtml === false || !this.rt.lib ? false : true\n // 插入全局引用变量 让 empRuntime 可以提前实例化 不需要在页面重复实例化\n if (injectGlobalValToHtml) {\n const injectData: any = {frameworkLib: frameworkGlobal, runtimeLib: this.rt.global}\n if (this.fk.name && this.fk.name !== 'none') injectData.framework = this.fk.name\n injectHtml.push({\n // type: 'js',\n tagName: 'script',\n innerHTML: `EMPShareGlobalVal=${JSON.stringify(injectData)}`,\n })\n }\n }\n public fk!: Required<frameworkOptions>\n private resetFramework() {\n if (!this.op.empRuntime) return\n const {framework, frameworkGlobal, frameworkLib} = this.op.empRuntime\n //\n this.fk = {\n name: 'none',\n version: 0,\n entry: '',\n global: frameworkGlobal || '',\n lib: frameworkLib || '',\n libs: [],\n }\n //\n if (typeof framework === 'string') {\n this.fk.name = framework as any\n }\n // TODO 通用 CDN 的适配方案\n else if (typeof framework === 'object' && Object.keys(framework).length > 0) {\n // 默认 框架名 为入口\n framework.entry = framework.entry ? framework.entry : framework.name\n this.fk = deepAssign(this.fk, framework)\n }\n }\n public rt!: Required<runtimeLibType>\n private resetRuntime() {\n const {empRuntime} = this.op\n if (!empRuntime) return\n const global = empRuntime.runtimeGlobal || shareGlobalName\n const lib = empRuntime.runtimeLib ? empRuntime.runtimeLib : empRuntime.runtime?.lib ? empRuntime.runtime.lib : ''\n this.rt = {\n lib,\n global,\n }\n }\n private setExternal() {\n if (!this.op.empRuntime) return\n const {store, externalsLib} = this\n const {empRuntime} = this.op\n const {shareLib} = empRuntime\n //\n const externalRuntime = this.rt.lib\n ? {\n '@module-federation/runtime': `MFRuntime`,\n '@module-federation/sdk': `MFSDK`,\n }\n : {}\n const externals = {}\n for (const [key, value] of Object.entries(externalRuntime)) {\n externals[key] = `${this.rt.global}.${value}`\n }\n /**\n * TODO\n * 框架相关内容需要移除 share 由外部简化配置实现\n */\n if (this.fk.name === 'react' && !shareLib && this.fk.global) {\n const version = this.fk.version\n const externalReact = {\n react: `React`,\n 'react-dom': `ReactDOM`,\n }\n if (this.fk.entry === 'reactRouter') {\n externalReact['react-router-dom'] = 'ReactRouterDOM'\n }\n for (const [key, value] of Object.entries(externalReact)) {\n externals[key] = `${this.fk.global}.${value}`\n }\n if ([17, 18, 19].includes(version)) {\n externals['react-dom/client'] = this.fk.global\n externals['react/jsx-runtime'] = this.fk.global\n externals['react/jsx-dev-runtime'] = this.fk.global\n }\n }\n if (shareLib) {\n externalsLib.map(v => {\n if (v.type === 'js' && v.module && v.global) {\n externals[v.module] = `${this.fk.global}.${v.global}`\n }\n })\n }\n if (empRuntime.setExternals) empRuntime.setExternals(externals, this.fk.global, this.rt.global)\n //\n // console.log('externals in plugin', externals)\n store.chain.merge({externals})\n }\n private setRuntimeLib() {\n if (!this.op.empRuntime) return\n\n const {shareLib} = this.op.empRuntime\n const {store, injectHtml} = this\n const {empRuntime} = this.op\n if (!this.rt.lib) {\n // 内置 this.rt.lib\n store.chain.plugin('plugin-emp-share-framework').use(EmpShareRemoteLibPlugin, [empRuntime])\n }\n // 统一封装到 frameworkLib\n else if (this.rt.lib === 'useFrameworkLib' && !shareLib) {\n } else {\n // 插入 runtime\n injectHtml.push({tagName: 'script', pos: 'head', attributes: {src: this.rt.lib}})\n }\n }\n private setMfName() {\n if (this.op.name) {\n this.op.name = this.store.encodeVarName(this.op.name)\n if (this.op.name !== this.store.empConfig.output.uniqueName) {\n this.store.chain.output.set('uniqueName', this.op.name)\n }\n } else {\n this.op.name = this.store.empConfig.output.uniqueName\n }\n }\n private setMF() {\n const o = this.op\n const {store} = this\n if (o.name) {\n const op = store.deepAssign<ModuleFederationPluginOptions & {empRuntime: any}>(\n {\n filename: 'emp.js',\n manifest: false,\n dts: false,\n dev: {\n disableDynamicRemoteTypeHints: true,\n },\n },\n o,\n )\n if (op.empRuntime) {\n delete op.empRuntime\n }\n store.chain.plugin('plugin-emp-share').use(ModuleFederationPlugin, [op])\n }\n }\n private setShareLib() {\n if (!this.op.empRuntime) return\n const {shareLib} = this.op.empRuntime\n const {externalsLib, injectHtml} = this\n if (shareLib && typeof shareLib === 'object') {\n for (const [k, v] of Object.entries(shareLib)) {\n let externalsItem: ExternalsItemType = {}\n externalsItem.module = k\n //增加下划线 支持lodash 等特殊符号的问题 如 _@http\n\n if (typeof v === 'string') {\n const cb: any = v.match(exp) || []\n if (cb.length > 0) {\n externalsItem.global = cb[1]\n externalsItem.entry = cb[2]\n externalsItem.type = 'js'\n externalsLib.push(externalsItem)\n externalsItem = {}\n } else {\n externalsItem.global = ''\n externalsItem.entry = v\n externalsItem.type = 'js'\n externalsLib.push(externalsItem)\n externalsItem = {}\n }\n } else if (Array.isArray(v)) {\n v.map(vo => {\n if (!vo) return\n const isCSS = vo.split('?')[0].endsWith('.css')\n if (isCSS) {\n externalsItem.entry = vo\n externalsItem.type = 'css'\n } else {\n const cb: any = vo.match(exp) || []\n if (cb.length > 0) {\n externalsItem.global = cb[1]\n externalsItem.entry = cb[2]\n externalsItem.type = 'js'\n } else {\n externalsItem.global = ''\n externalsItem.entry = vo\n externalsItem.type = 'js'\n }\n }\n externalsLib.push(externalsItem)\n externalsItem = {}\n })\n } else if (typeof v === 'object' && v.entry) {\n externalsItem.entry = v.entry\n externalsItem.global = v.global\n externalsItem.type = v.type\n externalsLib.push(externalsItem)\n externalsItem = {}\n }\n }\n // console.log(externalsLib)\n externalsLib.map(v => {\n if (v.type === 'js') {\n injectHtml.push({\n attributes: {\n src: v.entry,\n },\n tagName: 'script',\n })\n } else if (v.type === 'css') {\n injectHtml.push({\n attributes: {\n href: v.entry,\n rel: 'stylesheet',\n },\n tagName: 'link',\n })\n }\n })\n }\n }\n}\n","export const externalReact = (o: any, globalVal: string) => {\n o = Object.assign(o, {\n react: `${globalVal}.React`,\n 'react-dom': `${globalVal}.ReactDOM`,\n 'react-dom/client': globalVal,\n 'react/jsx-runtime': globalVal,\n 'react/jsx-dev-runtime': globalVal,\n 'react-router-dom': `${globalVal}.ReactRouterDOM`,\n })\n return o\n}\n","export const externalVue = (o: any, globalVal: string) => {\n o = Object.assign(o, {\n vue: `${globalVal}.Vue`,\n 'vue-router': `${globalVal}.VueRouter`,\n })\n return o\n}\n","import type {GlobalStore} from '@empjs/cli'\nimport {EmpShare} from './share'\nimport type {EMPPluginShareType} from './types'\n//\nexport * from 'src/framework/react/config'\nexport * from 'src/framework/vue/config'\n//\nexport const pluginRspackEmpShare = (o: EMPPluginShareType = {}) => {\n return {\n name: '@empjs/share',\n async rsConfig(store: GlobalStore) {\n //\n if (o.manifest === true) {\n o.manifest = {\n fileName: 'emp.json',\n }\n } else if (typeof o.manifest === 'object') {\n o.manifest = store.deepAssign({fileName: 'emp.json'}, o.manifest)\n }\n const empShare = new EmpShare(o, store)\n empShare.setup()\n },\n }\n}\nexport default pluginRspackEmpShare\n","import {default as pluginRspackEmpShare} from 'src/plugins/rspack'\nexport default pluginRspackEmpShare\nexport * from 'src/plugins/rspack'\n"],"mappings":"AAAO,IAAMA,EAAcC,GAAoB,wBAAwBA,CAAO,GAEvE,SAASC,EAAcC,KAAgBC,EAAiB,CAC7D,QAAWC,KAAUD,EACnB,QAAWE,KAAKD,EAAQ,CACtB,IAAME,EAAKF,EAAOC,CAAC,EACjBE,EAAKL,EAAOG,CAAC,EACf,GAAI,OAAOC,CAAE,GAAKA,GAAM,OAAOC,CAAE,IAAMA,EAAI,CACzCL,EAAOG,CAAC,EAAIJ,EAAWM,EAAID,CAAE,EAC7B,QACF,CACAJ,EAAOG,CAAC,EAAID,EAAOC,CAAC,CACtB,CAEF,OAAOH,CACT,CAMO,IAAMM,EAAQ,GACRC,EAAMD,EAAQ,QAAQ,IAAI,KAAK,QAAS,aAAa,EAAI,IAAM,CAAC,ECtBtE,IAAME,EAAkB,oBCA/B,OAAQ,0BAAAC,MAA6B,qCCGrC,IAAM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ign","target","sources","source","k","vs","vt","isDev","log","shareGlobalName","ModuleFederationPlugin","getShareRuntimeEntry","url","content","importJsVm","EmpShareRemoteLibPlugin","op","compiler","webpack","entry","getRuntimeLib","host","mode","entry","exp","EmpShare","op","store","injectHtml","url","getRuntimeLib","libs","empRuntime","frameworkGlobal","injectData","framework","frameworkLib","deepAssign","global","shareGlobalName","lib","externalsLib","shareLib","externalRuntime","externals","key","value","version","externalReact","v","EmpShareRemoteLibPlugin","o","ModuleFederationPlugin","k","externalsItem","cb","vo","externalReact","o","globalVal","externalVue","o","globalVal","pluginRspackEmpShare","o","store","EmpShare","rspack_default","src_default","rspack_default"]}
|
|
1
|
+
{"version":3,"sources":["../src/helper/index.ts","../src/helper/config.ts","../src/helper/rspack.ts","../src/plugins/rspack/plugin.ts","../src/plugins/rspack/utils.ts","../src/plugins/rspack/share.ts","../src/framework/react/config.ts","../src/framework/vue/config.ts","../src/plugins/rspack/index.ts","../src/index.ts"],"sourcesContent":["export const importJsVm = (content: string) => `data:text/javascript,${content}`\n\nexport function deepAssign<T>(target: any, ...sources: any): T {\n for (const source of sources) {\n for (const k in source) {\n const vs = source[k],\n vt = target[k]\n if (Object(vs) == vs && Object(vt) === vt) {\n target[k] = deepAssign(vt, vs)\n continue\n }\n target[k] = source[k]\n }\n }\n return target\n}\n\nexport const checkVersion = (version: string) => (version ? Number(version.split('.')[0]) : 0)\nexport const isPromise = (p: any) => p && Object.prototype.toString.call(p) === '[object Promise]'\n\n//\nexport const isDev = process.env.EMPSHARE_ENV === 'dev'\nexport const log = isDev ? console.log.bind(console, '[EMP Share]') : () => {}\n","export const shareGlobalName = 'EMP_SHARE_RUNTIME'\n","export {ModuleFederationPlugin} from '@module-federation/enhanced/rspack'\n","import type {Compiler} from '@rspack/core'\nimport {importJsVm} from 'src/helper'\nimport type {EMPSHARERuntimeOptions} from './types'\n\nconst getShareRuntimeEntry = url => {\n const content = [`import '${url}'`].join('\\n')\n return importJsVm(content)\n}\n// 当没有设置 runtimeLib 时候需要内置\nexport class EmpShareRemoteLibPlugin {\n options: EMPSHARERuntimeOptions\n constructor(op: EMPSHARERuntimeOptions) {\n this.options = op\n }\n apply(compiler: Compiler) {\n const {webpack} = compiler\n const entry = getShareRuntimeEntry('@empjs/share/library')\n new webpack.EntryPlugin(compiler.context, entry, {\n name: undefined,\n }).apply(compiler)\n }\n}\n","import type {EMPSHARERuntimeOptions} from './types'\nexport function getRuntimeLib(host: EMPSHARERuntimeOptions['frameworkLib'], mode: string, entry = 'runtime') {\n if (typeof host === 'string') {\n if (entry === 'runtime') {\n return `${host}/runtime${mode === 'development' ? '.development' : ''}.umd.js`\n } else {\n return `${host}/${entry}.${mode}.umd.js`\n }\n } else if (typeof host === 'object') {\n if (mode === 'development') return host.dev\n else return host.prod\n }\n return ''\n}\n","import type {GlobalStore} from '@empjs/cli'\nimport {deepAssign} from 'src/helper'\nimport {shareGlobalName} from 'src/helper/config'\nimport {ModuleFederationPlugin} from 'src/helper/rspack'\nimport {EmpShareRemoteLibPlugin} from './plugin'\nimport type {\n EMPPluginShareType,\n ExternalsItemType,\n frameworkOptions,\n ModuleFederationPluginOptions,\n runtimeLibType,\n} from './types'\nimport {getRuntimeLib} from './utils'\n\nconst exp = /^([0-9a-zA-Z_\\s]+)@(.*)/\nexport class EmpShare {\n private op: EMPPluginShareType\n private store: GlobalStore\n /**\n * 注入资源\n */\n private injectHtml: any[] = []\n /**\n * 兼容 shareLib\n */\n private externalsLib: ExternalsItemType[] = []\n constructor(op: EMPPluginShareType, store: GlobalStore) {\n this.op = op || {}\n this.store = store\n }\n setup() {\n this.resetRuntime()\n this.resetFramework()\n this.setMfName() //设置 mfName 默认为 uniqueName\n this.setMF() // 设置 MF 配置\n this.injectGlobalVal() // 插入全局变量 方便emp外的项目调用\n this.injectFramework() // 插入ui框架库\n this.setShareLib() //兼容 emp Sharelib的共享模型设置\n this.setRuntimeLib() // 设置 MF SDK\n this.injectToHtml() //触发插入动作\n this.setExternal() // 设置 external 降低包体\n }\n private injectToHtml() {\n const {store, injectHtml} = this\n if (injectHtml.length > 0) {\n store.injectTags(injectHtml, 'EMPShare')\n }\n }\n private injectFramework() {\n if (this.fk && this.fk.libs.length > 0) {\n return this.injectFkLibs(this.fk.libs)\n }\n if (!this.op.empRuntime || !this.fk.lib) return\n const {store, injectHtml} = this\n if (this.fk.lib) {\n const url = getRuntimeLib(this.fk.lib, store.mode, this.fk.entry)\n injectHtml.push({\n attributes: {\n src: url,\n },\n tagName: 'script',\n })\n }\n }\n private injectFkLibs(libs: string[]) {\n libs.map(url => {\n if (url.endsWith('.css')) {\n return this.injectHtml.push({\n attributes: {\n href: url,\n rel: 'stylesheet',\n },\n tagName: 'link',\n })\n }\n this.injectHtml.push({\n attributes: {\n src: url,\n },\n tagName: 'script',\n })\n })\n }\n private injectGlobalVal() {\n if (!this.op.empRuntime) return\n const {empRuntime} = this.op\n const {injectHtml} = this\n const frameworkGlobal = this.fk.global || (empRuntime.shareLib ? 'window' : '')\n const injectGlobalValToHtml = empRuntime.injectGlobalValToHtml === false || !this.rt.lib ? false : true\n // 插入全局引用变量 让 empRuntime 可以提前实例化 不需要在页面重复实例化\n if (injectGlobalValToHtml) {\n const injectData: any = {frameworkLib: frameworkGlobal, runtimeLib: this.rt.global}\n if (this.fk.name && this.fk.name !== 'none') injectData.framework = this.fk.name\n injectHtml.push({\n // type: 'js',\n tagName: 'script',\n innerHTML: `EMPShareGlobalVal=${JSON.stringify(injectData)}`,\n })\n }\n }\n public fk!: Required<frameworkOptions>\n private resetFramework() {\n if (!this.op.empRuntime) return\n const {framework, frameworkGlobal, frameworkLib} = this.op.empRuntime\n //\n this.fk = {\n name: 'none',\n version: 0,\n entry: '',\n global: frameworkGlobal || '',\n lib: frameworkLib || '',\n libs: [],\n }\n //\n if (typeof framework === 'string') {\n this.fk.name = framework as any\n }\n // TODO 通用 CDN 的适配方案\n else if (typeof framework === 'object' && Object.keys(framework).length > 0) {\n // 默认 框架名 为入口\n framework.entry = framework.entry ? framework.entry : framework.name\n this.fk = deepAssign(this.fk, framework)\n }\n }\n public rt!: Required<runtimeLibType>\n private resetRuntime() {\n const {empRuntime} = this.op\n if (!empRuntime) return\n const global = empRuntime.runtimeGlobal || shareGlobalName\n const lib = empRuntime.runtimeLib ? empRuntime.runtimeLib : empRuntime.runtime?.lib ? empRuntime.runtime.lib : ''\n this.rt = {\n lib,\n global,\n }\n }\n private setExternal() {\n if (!this.op.empRuntime) return\n const {store, externalsLib} = this\n const {empRuntime} = this.op\n const {shareLib} = empRuntime\n //\n const externalRuntime = this.rt.lib\n ? {\n '@module-federation/runtime': `MFRuntime`,\n '@module-federation/sdk': `MFSDK`,\n }\n : {}\n const externals = {}\n for (const [key, value] of Object.entries(externalRuntime)) {\n externals[key] = `${this.rt.global}.${value}`\n }\n /**\n * TODO\n * 框架相关内容需要移除 share 由外部简化配置实现\n */\n if (this.fk.name === 'react' && !shareLib && this.fk.global) {\n const version = this.fk.version\n const externalReact = {\n react: `React`,\n 'react-dom': `ReactDOM`,\n }\n if (this.fk.entry === 'reactRouter') {\n externalReact['react-router-dom'] = 'ReactRouterDOM'\n }\n for (const [key, value] of Object.entries(externalReact)) {\n externals[key] = `${this.fk.global}.${value}`\n }\n if ([17, 18, 19].includes(version)) {\n externals['react-dom/client'] = this.fk.global\n externals['react/jsx-runtime'] = this.fk.global\n externals['react/jsx-dev-runtime'] = this.fk.global\n }\n }\n if (shareLib) {\n externalsLib.map(v => {\n if (v.type === 'js' && v.module && v.global) {\n externals[v.module] = `${this.fk.global}.${v.global}`\n }\n })\n }\n if (empRuntime.setExternals) empRuntime.setExternals(externals, this.fk.global, this.rt.global)\n //\n // console.log('externals in plugin', externals)\n store.chain.merge({externals})\n }\n private setRuntimeLib() {\n if (!this.op.empRuntime) return\n\n const {shareLib} = this.op.empRuntime\n const {store, injectHtml} = this\n const {empRuntime} = this.op\n if (!this.rt.lib) {\n // 内置 this.rt.lib\n store.chain.plugin('plugin-emp-share-framework').use(EmpShareRemoteLibPlugin, [empRuntime])\n }\n // 统一封装到 frameworkLib\n else if (this.rt.lib === 'useFrameworkLib' && !shareLib) {\n } else {\n // 插入 runtime\n injectHtml.push({tagName: 'script', pos: 'head', attributes: {src: this.rt.lib}})\n }\n }\n private setMfName() {\n if (this.op.name) {\n this.op.name = this.store.encodeVarName(this.op.name)\n if (this.op.name !== this.store.empConfig.output.uniqueName) {\n this.store.chain.output.set('uniqueName', this.op.name)\n }\n } else {\n this.op.name = this.store.empConfig.output.uniqueName\n }\n }\n private setMF() {\n const o = this.op\n const {store} = this\n if (o.name) {\n const op = store.deepAssign<ModuleFederationPluginOptions & {empRuntime: any}>(\n {\n filename: 'emp.js',\n manifest: false,\n dts: false,\n dev: {\n disableDynamicRemoteTypeHints: true,\n },\n },\n o,\n )\n //\n if (o.dev === false) op.dev = false\n //\n if (op.empRuntime) {\n delete op.empRuntime\n }\n store.chain.plugin('plugin-emp-share').use(ModuleFederationPlugin, [op])\n }\n }\n private setShareLib() {\n if (!this.op.empRuntime) return\n const {shareLib} = this.op.empRuntime\n const {externalsLib, injectHtml} = this\n if (shareLib && typeof shareLib === 'object') {\n for (const [k, v] of Object.entries(shareLib)) {\n let externalsItem: ExternalsItemType = {}\n externalsItem.module = k\n //增加下划线 支持lodash 等特殊符号的问题 如 _@http\n\n if (typeof v === 'string') {\n const cb: any = v.match(exp) || []\n if (cb.length > 0) {\n externalsItem.global = cb[1]\n externalsItem.entry = cb[2]\n externalsItem.type = 'js'\n externalsLib.push(externalsItem)\n externalsItem = {}\n } else {\n externalsItem.global = ''\n externalsItem.entry = v\n externalsItem.type = 'js'\n externalsLib.push(externalsItem)\n externalsItem = {}\n }\n } else if (Array.isArray(v)) {\n v.map(vo => {\n if (!vo) return\n const isCSS = vo.split('?')[0].endsWith('.css')\n if (isCSS) {\n externalsItem.entry = vo\n externalsItem.type = 'css'\n } else {\n const cb: any = vo.match(exp) || []\n if (cb.length > 0) {\n externalsItem.global = cb[1]\n externalsItem.entry = cb[2]\n externalsItem.type = 'js'\n } else {\n externalsItem.global = ''\n externalsItem.entry = vo\n externalsItem.type = 'js'\n }\n }\n externalsLib.push(externalsItem)\n externalsItem = {}\n })\n } else if (typeof v === 'object' && v.entry) {\n externalsItem.entry = v.entry\n externalsItem.global = v.global\n externalsItem.type = v.type\n externalsLib.push(externalsItem)\n externalsItem = {}\n }\n }\n // console.log(externalsLib)\n externalsLib.map(v => {\n if (v.type === 'js') {\n injectHtml.push({\n attributes: {\n src: v.entry,\n },\n tagName: 'script',\n })\n } else if (v.type === 'css') {\n injectHtml.push({\n attributes: {\n href: v.entry,\n rel: 'stylesheet',\n },\n tagName: 'link',\n })\n }\n })\n }\n }\n}\n","export const externalReact = (o: any, globalVal: string) => {\n o = Object.assign(o, {\n react: `${globalVal}.React`,\n 'react-dom': `${globalVal}.ReactDOM`,\n 'react-dom/client': globalVal,\n 'react/jsx-runtime': globalVal,\n 'react/jsx-dev-runtime': globalVal,\n 'react-router-dom': `${globalVal}.ReactRouterDOM`,\n })\n return o\n}\n","export const externalVue = (o: any, globalVal: string) => {\n o = Object.assign(o, {\n vue: `${globalVal}.Vue`,\n 'vue-router': `${globalVal}.VueRouter`,\n })\n return o\n}\n","import type {GlobalStore} from '@empjs/cli'\nimport {EmpShare} from './share'\nimport type {EMPPluginShareType} from './types'\n\n//\nexport * from 'src/framework/react/config'\nexport * from 'src/framework/vue/config'\n//\nexport const pluginRspackEmpShare = (o: EMPPluginShareType = {}) => {\n return {\n name: '@empjs/share',\n async rsConfig(store: GlobalStore) {\n //\n if (o.manifest === true) {\n o.manifest = {\n fileName: 'emp.json',\n }\n } else if (typeof o.manifest === 'object') {\n o.manifest = store.deepAssign({fileName: 'emp.json'}, o.manifest)\n }\n const empShare = new EmpShare(o, store)\n empShare.setup()\n },\n }\n}\nexport default pluginRspackEmpShare\n","import {default as pluginRspackEmpShare} from 'src/plugins/rspack'\nexport default pluginRspackEmpShare\nexport * from 'src/plugins/rspack'\n"],"mappings":"AAAO,IAAMA,EAAcC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,mBAAoBA,EACpB,oBAAqBA,EACrB,wBAAyBA,EACzB,mBAAoB,GAAGA,CAAS,iBAClC,CAAC,EACMD,GCTF,IAAME,EAAc,CAACC,EAAQC,KAClCD,EAAI,OAAO,OAAOA,EAAG,CACnB,IAAK,GAAGC,CAAS,OACjB,aAAc,GAAGA,CAAS,YAC5B,CAAC,EACMD,GCGF,IAAME,EAAuB,CAACC,EAAwB,CAAC,KACrD,CACL,KAAM,eACN,MAAM,SAASC,EAAoB,CAE7BD,EAAE,WAAa,GACjBA,EAAE,SAAW,CACX,SAAU,UACZ,EACS,OAAOA,EAAE,UAAa,WAC/BA,EAAE,SAAWC,EAAM,WAAW,CAAC,SAAU,UAAU,EAAGD,EAAE,QAAQ,GAEjD,IAAIE,EAASF,EAAGC,CAAK,EAC7B,MAAM,CACjB,CACF,GAEKE,EAAQJ,ECxBf,IAAOK,EAAQC","names":["importJsVm","content","deepAssign","target","sources","source","k","vs","vt","isDev","log","shareGlobalName","ModuleFederationPlugin","getShareRuntimeEntry","url","content","importJsVm","EmpShareRemoteLibPlugin","op","compiler","webpack","entry","getRuntimeLib","host","mode","entry","exp","EmpShare","op","store","injectHtml","url","getRuntimeLib","libs","empRuntime","frameworkGlobal","injectData","framework","frameworkLib","deepAssign","global","shareGlobalName","lib","externalsLib","shareLib","externalRuntime","externals","key","value","version","externalReact","v","EmpShareRemoteLibPlugin","o","ModuleFederationPlugin","k","externalsItem","cb","vo","externalReact","o","globalVal","externalVue","o","globalVal","pluginRspackEmpShare","o","store","EmpShare","rspack_default","src_default","rspack_default"]}
|
package/dist/rspack.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var u=Object.defineProperty;var
|
|
2
|
-
`);return b(e)},l=class{options;constructor(e){this.options=e}apply(e){let{webpack:t}=e,r=
|
|
1
|
+
"use strict";var u=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var S=(i,e)=>{for(var t in e)u(i,t,{get:e[t],enumerable:!0})},M=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of x(e))!E.call(i,n)&&n!==t&&u(i,n,{get:()=>e[n],enumerable:!(r=R(e,n))||r.enumerable});return i};var P=i=>M(u({},"__esModule",{value:!0}),i);var T={};S(T,{default:()=>N,externalReact:()=>O,externalVue:()=>H,pluginRspackEmpShare:()=>k});module.exports=P(T);var b=i=>`data:text/javascript,${i}`;function f(i,...e){for(let t of e)for(let r in t){let n=t[r],o=i[r];if(Object(n)==n&&Object(o)===o){i[r]=f(o,n);continue}i[r]=t[r]}return i}var v=!1,$=v?console.log.bind(console,"[EMP Share]"):()=>{};var y="EMP_SHARE_RUNTIME";var h=require("@module-federation/enhanced/rspack");var L=i=>{let e=[`import '${i}'`].join(`
|
|
2
|
+
`);return b(e)},l=class{options;constructor(e){this.options=e}apply(e){let{webpack:t}=e,r=L("@empjs/share/library");new t.EntryPlugin(e.context,r,{name:void 0}).apply(e)}};function g(i,e,t="runtime"){return typeof i=="string"?t==="runtime"?`${i}/runtime${e==="development"?".development":""}.umd.js`:`${i}/${t}.${e}.umd.js`:typeof i=="object"?e==="development"?i.dev:i.prod:""}var j=/^([0-9a-zA-Z_\s]+)@(.*)/,c=class{op;store;injectHtml=[];externalsLib=[];constructor(e,t){this.op=e||{},this.store=t}setup(){this.resetRuntime(),this.resetFramework(),this.setMfName(),this.setMF(),this.injectGlobalVal(),this.injectFramework(),this.setShareLib(),this.setRuntimeLib(),this.injectToHtml(),this.setExternal()}injectToHtml(){let{store:e,injectHtml:t}=this;t.length>0&&e.injectTags(t,"EMPShare")}injectFramework(){if(this.fk&&this.fk.libs.length>0)return this.injectFkLibs(this.fk.libs);if(!this.op.empRuntime||!this.fk.lib)return;let{store:e,injectHtml:t}=this;if(this.fk.lib){let r=g(this.fk.lib,e.mode,this.fk.entry);t.push({attributes:{src:r},tagName:"script"})}}injectFkLibs(e){e.map(t=>{if(t.endsWith(".css"))return this.injectHtml.push({attributes:{href:t,rel:"stylesheet"},tagName:"link"});this.injectHtml.push({attributes:{src:t},tagName:"script"})})}injectGlobalVal(){if(!this.op.empRuntime)return;let{empRuntime:e}=this.op,{injectHtml:t}=this,r=this.fk.global||(e.shareLib?"window":"");if(!(e.injectGlobalValToHtml===!1||!this.rt.lib)){let o={frameworkLib:r,runtimeLib:this.rt.global};this.fk.name&&this.fk.name!=="none"&&(o.framework=this.fk.name),t.push({tagName:"script",innerHTML:`EMPShareGlobalVal=${JSON.stringify(o)}`})}}fk;resetFramework(){if(!this.op.empRuntime)return;let{framework:e,frameworkGlobal:t,frameworkLib:r}=this.op.empRuntime;this.fk={name:"none",version:0,entry:"",global:t||"",lib:r||"",libs:[]},typeof e=="string"?this.fk.name=e:typeof e=="object"&&Object.keys(e).length>0&&(e.entry=e.entry?e.entry:e.name,this.fk=f(this.fk,e))}rt;resetRuntime(){let{empRuntime:e}=this.op;if(!e)return;let t=e.runtimeGlobal||y,r=e.runtimeLib?e.runtimeLib:e.runtime?.lib?e.runtime.lib:"";this.rt={lib:r,global:t}}setExternal(){if(!this.op.empRuntime)return;let{store:e,externalsLib:t}=this,{empRuntime:r}=this.op,{shareLib:n}=r,o=this.rt.lib?{"@module-federation/runtime":"MFRuntime","@module-federation/sdk":"MFSDK"}:{},s={};for(let[a,m]of Object.entries(o))s[a]=`${this.rt.global}.${m}`;if(this.fk.name==="react"&&!n&&this.fk.global){let a=this.fk.version,m={react:"React","react-dom":"ReactDOM"};this.fk.entry==="reactRouter"&&(m["react-router-dom"]="ReactRouterDOM");for(let[p,d]of Object.entries(m))s[p]=`${this.fk.global}.${d}`;[17,18,19].includes(a)&&(s["react-dom/client"]=this.fk.global,s["react/jsx-runtime"]=this.fk.global,s["react/jsx-dev-runtime"]=this.fk.global)}n&&t.map(a=>{a.type==="js"&&a.module&&a.global&&(s[a.module]=`${this.fk.global}.${a.global}`)}),r.setExternals&&r.setExternals(s,this.fk.global,this.rt.global),e.chain.merge({externals:s})}setRuntimeLib(){if(!this.op.empRuntime)return;let{shareLib:e}=this.op.empRuntime,{store:t,injectHtml:r}=this,{empRuntime:n}=this.op;this.rt.lib?this.rt.lib==="useFrameworkLib"&&!e||r.push({tagName:"script",pos:"head",attributes:{src:this.rt.lib}}):t.chain.plugin("plugin-emp-share-framework").use(l,[n])}setMfName(){this.op.name?(this.op.name=this.store.encodeVarName(this.op.name),this.op.name!==this.store.empConfig.output.uniqueName&&this.store.chain.output.set("uniqueName",this.op.name)):this.op.name=this.store.empConfig.output.uniqueName}setMF(){let e=this.op,{store:t}=this;if(e.name){let r=t.deepAssign({filename:"emp.js",manifest:!1,dts:!1,dev:{disableDynamicRemoteTypeHints:!0}},e);e.dev===!1&&(r.dev=!1),r.empRuntime&&delete r.empRuntime,t.chain.plugin("plugin-emp-share").use(h.ModuleFederationPlugin,[r])}}setShareLib(){if(!this.op.empRuntime)return;let{shareLib:e}=this.op.empRuntime,{externalsLib:t,injectHtml:r}=this;if(e&&typeof e=="object"){for(let[n,o]of Object.entries(e)){let s={};if(s.module=n,typeof o=="string"){let a=o.match(j)||[];a.length>0?(s.global=a[1],s.entry=a[2],s.type="js",t.push(s),s={}):(s.global="",s.entry=o,s.type="js",t.push(s),s={})}else Array.isArray(o)?o.map(a=>{if(!a)return;if(a.split("?")[0].endsWith(".css"))s.entry=a,s.type="css";else{let p=a.match(j)||[];p.length>0?(s.global=p[1],s.entry=p[2],s.type="js"):(s.global="",s.entry=a,s.type="js")}t.push(s),s={}}):typeof o=="object"&&o.entry&&(s.entry=o.entry,s.global=o.global,s.type=o.type,t.push(s),s={})}t.map(n=>{n.type==="js"?r.push({attributes:{src:n.entry},tagName:"script"}):n.type==="css"&&r.push({attributes:{href:n.entry,rel:"stylesheet"},tagName:"link"})})}}};var O=(i,e)=>(i=Object.assign(i,{react:`${e}.React`,"react-dom":`${e}.ReactDOM`,"react-dom/client":e,"react/jsx-runtime":e,"react/jsx-dev-runtime":e,"react-router-dom":`${e}.ReactRouterDOM`}),i);var H=(i,e)=>(i=Object.assign(i,{vue:`${e}.Vue`,"vue-router":`${e}.VueRouter`}),i);var k=(i={})=>({name:"@empjs/share",async rsConfig(e){i.manifest===!0?i.manifest={fileName:"emp.json"}:typeof i.manifest=="object"&&(i.manifest=e.deepAssign({fileName:"emp.json"},i.manifest)),new c(i,e).setup()}}),N=k;0&&(module.exports={externalReact,externalVue,pluginRspackEmpShare});
|
|
3
3
|
//# sourceMappingURL=rspack.cjs.map
|
package/dist/rspack.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugins/rspack/index.ts","../src/helper/index.ts","../src/helper/config.ts","../src/helper/rspack.ts","../src/plugins/rspack/plugin.ts","../src/plugins/rspack/utils.ts","../src/plugins/rspack/share.ts","../src/framework/react/config.ts","../src/framework/vue/config.ts"],"sourcesContent":["import type {GlobalStore} from '@empjs/cli'\nimport {EmpShare} from './share'\nimport type {EMPPluginShareType} from './types'\n//\nexport * from 'src/framework/react/config'\nexport * from 'src/framework/vue/config'\n//\nexport const pluginRspackEmpShare = (o: EMPPluginShareType = {}) => {\n return {\n name: '@empjs/share',\n async rsConfig(store: GlobalStore) {\n //\n if (o.manifest === true) {\n o.manifest = {\n fileName: 'emp.json',\n }\n } else if (typeof o.manifest === 'object') {\n o.manifest = store.deepAssign({fileName: 'emp.json'}, o.manifest)\n }\n const empShare = new EmpShare(o, store)\n empShare.setup()\n },\n }\n}\nexport default pluginRspackEmpShare\n","export const importJsVm = (content: string) => `data:text/javascript,${content}`\n\nexport function deepAssign<T>(target: any, ...sources: any): T {\n for (const source of sources) {\n for (const k in source) {\n const vs = source[k],\n vt = target[k]\n if (Object(vs) == vs && Object(vt) === vt) {\n target[k] = deepAssign(vt, vs)\n continue\n }\n target[k] = source[k]\n }\n }\n return target\n}\n\nexport const checkVersion = (version: string) => (version ? Number(version.split('.')[0]) : 0)\nexport const isPromise = (p: any) => p && Object.prototype.toString.call(p) === '[object Promise]'\n\n//\nexport const isDev = process.env.EMPSHARE_ENV === 'dev'\nexport const log = isDev ? console.log.bind(console, '[EMP Share]') : () => {}\n","export const shareGlobalName = 'EMP_SHARE_RUNTIME'\n","export {ModuleFederationPlugin} from '@module-federation/enhanced/rspack'\n","import type {Compiler} from '@rspack/core'\nimport {importJsVm} from 'src/helper'\nimport type {EMPSHARERuntimeOptions} from './types'\nconst getShareRuntimeEntry = url => {\n const content = [`import '${url}'`].join('\\n')\n return importJsVm(content)\n}\n// 当没有设置 runtimeLib 时候需要内置\nexport class EmpShareRemoteLibPlugin {\n options: EMPSHARERuntimeOptions\n constructor(op: EMPSHARERuntimeOptions) {\n this.options = op\n }\n apply(compiler: Compiler) {\n const {webpack} = compiler\n const entry = getShareRuntimeEntry('@empjs/share/library')\n new webpack.EntryPlugin(compiler.context, entry, {\n name: undefined,\n }).apply(compiler)\n }\n}\n","import type {EMPSHARERuntimeOptions} from './types'\nexport function getRuntimeLib(host: EMPSHARERuntimeOptions['frameworkLib'], mode: string, entry = 'runtime') {\n if (typeof host === 'string') {\n if (entry === 'runtime') {\n return `${host}/runtime${mode === 'development' ? '.development' : ''}.umd.js`\n } else {\n return `${host}/${entry}.${mode}.umd.js`\n }\n } else if (typeof host === 'object') {\n if (mode === 'development') return host.dev\n else return host.prod\n }\n return ''\n}\n","import type {GlobalStore} from '@empjs/cli'\nimport {deepAssign} from 'src/helper'\nimport {shareGlobalName} from 'src/helper/config'\nimport {ModuleFederationPlugin} from 'src/helper/rspack'\nimport {EmpShareRemoteLibPlugin} from './plugin'\nimport type {\n EMPPluginShareType,\n ExternalsItemType,\n ModuleFederationPluginOptions,\n frameworkOptions,\n runtimeLibType,\n} from './types'\nimport {getRuntimeLib} from './utils'\nconst exp = /^([0-9a-zA-Z_\\s]+)@(.*)/\nexport class EmpShare {\n private op: EMPPluginShareType\n private store: GlobalStore\n /**\n * 注入资源\n */\n private injectHtml: any[] = []\n /**\n * 兼容 shareLib\n */\n private externalsLib: ExternalsItemType[] = []\n constructor(op: EMPPluginShareType, store: GlobalStore) {\n this.op = op || {}\n this.store = store\n }\n setup() {\n this.resetRuntime()\n this.resetFramework()\n this.setMfName() //设置 mfName 默认为 uniqueName\n this.setMF() // 设置 MF 配置\n this.injectGlobalVal() // 插入全局变量 方便emp外的项目调用\n this.injectFramework() // 插入ui框架库\n this.setShareLib() //兼容 emp Sharelib的共享模型设置\n this.setRuntimeLib() // 设置 MF SDK\n this.injectToHtml() //触发插入动作\n this.setExternal() // 设置 external 降低包体\n }\n private injectToHtml() {\n const {store, injectHtml} = this\n if (injectHtml.length > 0) {\n store.injectTags(injectHtml, 'EMPShare')\n }\n }\n private injectFramework() {\n if (this.fk.libs.length > 0) {\n return this.injectFkLibs(this.fk.libs)\n }\n if (!this.op.empRuntime || !this.fk.lib) return\n const {store, injectHtml} = this\n if (this.fk.lib) {\n const url = getRuntimeLib(this.fk.lib, store.mode, this.fk.entry)\n injectHtml.push({\n attributes: {\n src: url,\n },\n tagName: 'script',\n })\n }\n }\n private injectFkLibs(libs: string[]) {\n libs.map(url => {\n if (url.endsWith('.css')) {\n return this.injectHtml.push({\n attributes: {\n href: url,\n rel: 'stylesheet',\n },\n tagName: 'link',\n })\n }\n this.injectHtml.push({\n attributes: {\n src: url,\n },\n tagName: 'script',\n })\n })\n }\n private injectGlobalVal() {\n if (!this.op.empRuntime) return\n const {empRuntime} = this.op\n const {injectHtml} = this\n const frameworkGlobal = this.fk.global || (empRuntime.shareLib ? 'window' : '')\n const injectGlobalValToHtml = empRuntime.injectGlobalValToHtml === false || !this.rt.lib ? false : true\n // 插入全局引用变量 让 empRuntime 可以提前实例化 不需要在页面重复实例化\n if (injectGlobalValToHtml) {\n const injectData: any = {frameworkLib: frameworkGlobal, runtimeLib: this.rt.global}\n if (this.fk.name && this.fk.name !== 'none') injectData.framework = this.fk.name\n injectHtml.push({\n // type: 'js',\n tagName: 'script',\n innerHTML: `EMPShareGlobalVal=${JSON.stringify(injectData)}`,\n })\n }\n }\n public fk!: Required<frameworkOptions>\n private resetFramework() {\n if (!this.op.empRuntime) return\n const {framework, frameworkGlobal, frameworkLib} = this.op.empRuntime\n //\n this.fk = {\n name: 'none',\n version: 0,\n entry: '',\n global: frameworkGlobal || '',\n lib: frameworkLib || '',\n libs: [],\n }\n //\n if (typeof framework === 'string') {\n this.fk.name = framework as any\n }\n // TODO 通用 CDN 的适配方案\n else if (typeof framework === 'object' && Object.keys(framework).length > 0) {\n // 默认 框架名 为入口\n framework.entry = framework.entry ? framework.entry : framework.name\n this.fk = deepAssign(this.fk, framework)\n }\n }\n public rt!: Required<runtimeLibType>\n private resetRuntime() {\n const {empRuntime} = this.op\n if (!empRuntime) return\n const global = empRuntime.runtimeGlobal || shareGlobalName\n const lib = empRuntime.runtimeLib ? empRuntime.runtimeLib : empRuntime.runtime?.lib ? empRuntime.runtime.lib : ''\n this.rt = {\n lib,\n global,\n }\n }\n private setExternal() {\n if (!this.op.empRuntime) return\n const {store, externalsLib} = this\n const {empRuntime} = this.op\n const {shareLib} = empRuntime\n //\n const externalRuntime = this.rt.lib\n ? {\n '@module-federation/runtime': `MFRuntime`,\n '@module-federation/sdk': `MFSDK`,\n }\n : {}\n const externals = {}\n for (const [key, value] of Object.entries(externalRuntime)) {\n externals[key] = `${this.rt.global}.${value}`\n }\n /**\n * TODO\n * 框架相关内容需要移除 share 由外部简化配置实现\n */\n if (this.fk.name === 'react' && !shareLib && this.fk.global) {\n const version = this.fk.version\n const externalReact = {\n react: `React`,\n 'react-dom': `ReactDOM`,\n }\n if (this.fk.entry === 'reactRouter') {\n externalReact['react-router-dom'] = 'ReactRouterDOM'\n }\n for (const [key, value] of Object.entries(externalReact)) {\n externals[key] = `${this.fk.global}.${value}`\n }\n if ([17, 18, 19].includes(version)) {\n externals['react-dom/client'] = this.fk.global\n externals['react/jsx-runtime'] = this.fk.global\n externals['react/jsx-dev-runtime'] = this.fk.global\n }\n }\n if (shareLib) {\n externalsLib.map(v => {\n if (v.type === 'js' && v.module && v.global) {\n externals[v.module] = `${this.fk.global}.${v.global}`\n }\n })\n }\n if (empRuntime.setExternals) empRuntime.setExternals(externals, this.fk.global, this.rt.global)\n //\n // console.log('externals in plugin', externals)\n store.chain.merge({externals})\n }\n private setRuntimeLib() {\n if (!this.op.empRuntime) return\n\n const {shareLib} = this.op.empRuntime\n const {store, injectHtml} = this\n const {empRuntime} = this.op\n if (!this.rt.lib) {\n // 内置 this.rt.lib\n store.chain.plugin('plugin-emp-share-framework').use(EmpShareRemoteLibPlugin, [empRuntime])\n }\n // 统一封装到 frameworkLib\n else if (this.rt.lib === 'useFrameworkLib' && !shareLib) {\n } else {\n // 插入 runtime\n injectHtml.push({tagName: 'script', pos: 'head', attributes: {src: this.rt.lib}})\n }\n }\n private setMfName() {\n if (this.op.name) {\n this.op.name = this.store.encodeVarName(this.op.name)\n if (this.op.name !== this.store.empConfig.output.uniqueName) {\n this.store.chain.output.set('uniqueName', this.op.name)\n }\n } else {\n this.op.name = this.store.empConfig.output.uniqueName\n }\n }\n private setMF() {\n const o = this.op\n const {store} = this\n if (o.name) {\n const op = store.deepAssign<ModuleFederationPluginOptions & {empRuntime: any}>(\n {\n filename: 'emp.js',\n manifest: false,\n dts: false,\n dev: {\n disableDynamicRemoteTypeHints: true,\n },\n },\n o,\n )\n if (op.empRuntime) {\n delete op.empRuntime\n }\n store.chain.plugin('plugin-emp-share').use(ModuleFederationPlugin, [op])\n }\n }\n private setShareLib() {\n if (!this.op.empRuntime) return\n const {shareLib} = this.op.empRuntime\n const {externalsLib, injectHtml} = this\n if (shareLib && typeof shareLib === 'object') {\n for (const [k, v] of Object.entries(shareLib)) {\n let externalsItem: ExternalsItemType = {}\n externalsItem.module = k\n //增加下划线 支持lodash 等特殊符号的问题 如 _@http\n\n if (typeof v === 'string') {\n const cb: any = v.match(exp) || []\n if (cb.length > 0) {\n externalsItem.global = cb[1]\n externalsItem.entry = cb[2]\n externalsItem.type = 'js'\n externalsLib.push(externalsItem)\n externalsItem = {}\n } else {\n externalsItem.global = ''\n externalsItem.entry = v\n externalsItem.type = 'js'\n externalsLib.push(externalsItem)\n externalsItem = {}\n }\n } else if (Array.isArray(v)) {\n v.map(vo => {\n if (!vo) return\n const isCSS = vo.split('?')[0].endsWith('.css')\n if (isCSS) {\n externalsItem.entry = vo\n externalsItem.type = 'css'\n } else {\n const cb: any = vo.match(exp) || []\n if (cb.length > 0) {\n externalsItem.global = cb[1]\n externalsItem.entry = cb[2]\n externalsItem.type = 'js'\n } else {\n externalsItem.global = ''\n externalsItem.entry = vo\n externalsItem.type = 'js'\n }\n }\n externalsLib.push(externalsItem)\n externalsItem = {}\n })\n } else if (typeof v === 'object' && v.entry) {\n externalsItem.entry = v.entry\n externalsItem.global = v.global\n externalsItem.type = v.type\n externalsLib.push(externalsItem)\n externalsItem = {}\n }\n }\n // console.log(externalsLib)\n externalsLib.map(v => {\n if (v.type === 'js') {\n injectHtml.push({\n attributes: {\n src: v.entry,\n },\n tagName: 'script',\n })\n } else if (v.type === 'css') {\n injectHtml.push({\n attributes: {\n href: v.entry,\n rel: 'stylesheet',\n },\n tagName: 'link',\n })\n }\n })\n }\n }\n}\n","export const externalReact = (o: any, globalVal: string) => {\n o = Object.assign(o, {\n react: `${globalVal}.React`,\n 'react-dom': `${globalVal}.ReactDOM`,\n 'react-dom/client': globalVal,\n 'react/jsx-runtime': globalVal,\n 'react/jsx-dev-runtime': globalVal,\n 'react-router-dom': `${globalVal}.ReactRouterDOM`,\n })\n return o\n}\n","export const externalVue = (o: any, globalVal: string) => {\n o = Object.assign(o, {\n vue: `${globalVal}.Vue`,\n 'vue-router': `${globalVal}.VueRouter`,\n })\n return o\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,kBAAAC,EAAA,gBAAAC,EAAA,yBAAAC,IAAA,eAAAC,EAAAN,GCAO,IAAMO,EAAcC,GAAoB,wBAAwBA,CAAO,GAEvE,SAASC,EAAcC,KAAgBC,EAAiB,CAC7D,QAAWC,KAAU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O,OAAOA,EAAG,CACnB,IAAK,GAAGC,CAAS,OACjB,aAAc,GAAGA,CAAS,YAC5B,CAAC,EACMD,GREF,IAAME,EAAuB,CAACC,EAAwB,CAAC,KACrD,CACL,KAAM,eACN,MAAM,SAASC,EAAoB,CAE7BD,EAAE,WAAa,GACjBA,EAAE,SAAW,CACX,SAAU,UACZ,EACS,OAAOA,EAAE,UAAa,WAC/BA,EAAE,SAAWC,EAAM,WAAW,CAAC,SAAU,UAAU,EAAGD,EAAE,QAAQ,GAEjD,IAAIE,EAASF,EAAGC,CAAK,EAC7B,MAAM,CACjB,CACF,GAEKE,EAAQJ","names":["rspack_exports","__export","rspack_default","externalReact","externalVue","pluginRspackEmpShare","__toCommonJS","importJsVm","content","deepAssign","target","sources","source","k","vs","vt","isDev","log","shareGlobalName","import_rspack","getShareRuntimeEntry","url","content","importJsVm","EmpShareRemoteLibPlugin","op","compiler","webpack","entry","getRuntimeLib","host","mode","entry","exp","EmpShare","op","store","injectHtml","url","getRuntimeLib","libs","empRuntime","frameworkGlobal","injectData","framework","frameworkLib","deepAssign","global","shareGlobalName","lib","externalsLib","shareLib","externalRuntime","externals","key","value","version","externalReact","v","EmpShareRemoteLibPlugin","o","k","externalsItem","cb","vo","externalReact","o","globalVal","externalVue","o","globalVal","pluginRspackEmpShare","o","store","EmpShare","rspack_default"]}
|
|
1
|
+
{"version":3,"sources":["../src/plugins/rspack/index.ts","../src/helper/index.ts","../src/helper/config.ts","../src/helper/rspack.ts","../src/plugins/rspack/plugin.ts","../src/plugins/rspack/utils.ts","../src/plugins/rspack/share.ts","../src/framework/react/config.ts","../src/framework/vue/config.ts"],"sourcesContent":["import type {GlobalStore} from '@empjs/cli'\nimport {EmpShare} from './share'\nimport type {EMPPluginShareType} from './types'\n\n//\nexport * from 'src/framework/react/config'\nexport * from 'src/framework/vue/config'\n//\nexport const pluginRspackEmpShare = (o: EMPPluginShareType = {}) => {\n return {\n name: '@empjs/share',\n async rsConfig(store: GlobalStore) {\n //\n if (o.manifest === true) {\n o.manifest = {\n fileName: 'emp.json',\n }\n } else if (typeof o.manifest === 'object') {\n o.manifest = store.deepAssign({fileName: 'emp.json'}, o.manifest)\n }\n const empShare = new EmpShare(o, store)\n empShare.setup()\n },\n }\n}\nexport default pluginRspackEmpShare\n","export const importJsVm = (content: string) => `data:text/javascript,${content}`\n\nexport function deepAssign<T>(target: any, ...sources: any): T {\n for (const source of sources) {\n for (const k in source) {\n const vs = source[k],\n vt = target[k]\n if (Object(vs) == vs && Object(vt) === vt) {\n target[k] = deepAssign(vt, vs)\n continue\n }\n target[k] = source[k]\n }\n }\n return target\n}\n\nexport const checkVersion = (version: string) => (version ? Number(version.split('.')[0]) : 0)\nexport const isPromise = (p: any) => p && Object.prototype.toString.call(p) === '[object Promise]'\n\n//\nexport const isDev = process.env.EMPSHARE_ENV === 'dev'\nexport const log = isDev ? console.log.bind(console, '[EMP Share]') : () => {}\n","export const shareGlobalName = 'EMP_SHARE_RUNTIME'\n","export {ModuleFederationPlugin} from '@module-federation/enhanced/rspack'\n","import type {Compiler} from '@rspack/core'\nimport {importJsVm} from 'src/helper'\nimport type {EMPSHARERuntimeOptions} from './types'\n\nconst getShareRuntimeEntry = url => {\n const content = [`import '${url}'`].join('\\n')\n return importJsVm(content)\n}\n// 当没有设置 runtimeLib 时候需要内置\nexport class EmpShareRemoteLibPlugin {\n options: EMPSHARERuntimeOptions\n constructor(op: EMPSHARERuntimeOptions) {\n this.options = op\n }\n apply(compiler: Compiler) {\n const {webpack} = compiler\n const entry = getShareRuntimeEntry('@empjs/share/library')\n new webpack.EntryPlugin(compiler.context, entry, {\n name: undefined,\n }).apply(compiler)\n }\n}\n","import type {EMPSHARERuntimeOptions} from './types'\nexport function getRuntimeLib(host: EMPSHARERuntimeOptions['frameworkLib'], mode: string, entry = 'runtime') {\n if (typeof host === 'string') {\n if (entry === 'runtime') {\n return `${host}/runtime${mode === 'development' ? '.development' : ''}.umd.js`\n } else {\n return `${host}/${entry}.${mode}.umd.js`\n }\n } else if (typeof host === 'object') {\n if (mode === 'development') return host.dev\n else return host.prod\n }\n return ''\n}\n","import type {GlobalStore} from '@empjs/cli'\nimport {deepAssign} from 'src/helper'\nimport {shareGlobalName} from 'src/helper/config'\nimport {ModuleFederationPlugin} from 'src/helper/rspack'\nimport {EmpShareRemoteLibPlugin} from './plugin'\nimport type {\n EMPPluginShareType,\n ExternalsItemType,\n frameworkOptions,\n ModuleFederationPluginOptions,\n runtimeLibType,\n} from './types'\nimport {getRuntimeLib} from './utils'\n\nconst exp = /^([0-9a-zA-Z_\\s]+)@(.*)/\nexport class EmpShare {\n private op: EMPPluginShareType\n private store: GlobalStore\n /**\n * 注入资源\n */\n private injectHtml: any[] = []\n /**\n * 兼容 shareLib\n */\n private externalsLib: ExternalsItemType[] = []\n constructor(op: EMPPluginShareType, store: GlobalStore) {\n this.op = op || {}\n this.store = store\n }\n setup() {\n this.resetRuntime()\n this.resetFramework()\n this.setMfName() //设置 mfName 默认为 uniqueName\n this.setMF() // 设置 MF 配置\n this.injectGlobalVal() // 插入全局变量 方便emp外的项目调用\n this.injectFramework() // 插入ui框架库\n this.setShareLib() //兼容 emp Sharelib的共享模型设置\n this.setRuntimeLib() // 设置 MF SDK\n this.injectToHtml() //触发插入动作\n this.setExternal() // 设置 external 降低包体\n }\n private injectToHtml() {\n const {store, injectHtml} = this\n if (injectHtml.length > 0) {\n store.injectTags(injectHtml, 'EMPShare')\n }\n }\n private injectFramework() {\n if (this.fk && this.fk.libs.length > 0) {\n return this.injectFkLibs(this.fk.libs)\n }\n if (!this.op.empRuntime || !this.fk.lib) return\n const {store, injectHtml} = this\n if (this.fk.lib) {\n const url = getRuntimeLib(this.fk.lib, store.mode, this.fk.entry)\n injectHtml.push({\n attributes: {\n src: url,\n },\n tagName: 'script',\n })\n }\n }\n private injectFkLibs(libs: string[]) {\n libs.map(url => {\n if (url.endsWith('.css')) {\n return this.injectHtml.push({\n attributes: {\n href: url,\n rel: 'stylesheet',\n },\n tagName: 'link',\n })\n }\n this.injectHtml.push({\n attributes: {\n src: url,\n },\n tagName: 'script',\n })\n })\n }\n private injectGlobalVal() {\n if (!this.op.empRuntime) return\n const {empRuntime} = this.op\n const {injectHtml} = this\n const frameworkGlobal = this.fk.global || (empRuntime.shareLib ? 'window' : '')\n const injectGlobalValToHtml = empRuntime.injectGlobalValToHtml === false || !this.rt.lib ? false : true\n // 插入全局引用变量 让 empRuntime 可以提前实例化 不需要在页面重复实例化\n if (injectGlobalValToHtml) {\n const injectData: any = {frameworkLib: frameworkGlobal, runtimeLib: this.rt.global}\n if (this.fk.name && this.fk.name !== 'none') injectData.framework = this.fk.name\n injectHtml.push({\n // type: 'js',\n tagName: 'script',\n innerHTML: `EMPShareGlobalVal=${JSON.stringify(injectData)}`,\n })\n }\n }\n public fk!: Required<frameworkOptions>\n private resetFramework() {\n if (!this.op.empRuntime) return\n const {framework, frameworkGlobal, frameworkLib} = this.op.empRuntime\n //\n this.fk = {\n name: 'none',\n version: 0,\n entry: '',\n global: frameworkGlobal || '',\n lib: frameworkLib || '',\n libs: [],\n }\n //\n if (typeof framework === 'string') {\n this.fk.name = framework as any\n }\n // TODO 通用 CDN 的适配方案\n else if (typeof framework === 'object' && Object.keys(framework).length > 0) {\n // 默认 框架名 为入口\n framework.entry = framework.entry ? framework.entry : framework.name\n this.fk = deepAssign(this.fk, framework)\n }\n }\n public rt!: Required<runtimeLibType>\n private resetRuntime() {\n const {empRuntime} = this.op\n if (!empRuntime) return\n const global = empRuntime.runtimeGlobal || shareGlobalName\n const lib = empRuntime.runtimeLib ? empRuntime.runtimeLib : empRuntime.runtime?.lib ? empRuntime.runtime.lib : ''\n this.rt = {\n lib,\n global,\n }\n }\n private setExternal() {\n if (!this.op.empRuntime) return\n const {store, externalsLib} = this\n const {empRuntime} = this.op\n const {shareLib} = empRuntime\n //\n const externalRuntime = this.rt.lib\n ? {\n '@module-federation/runtime': `MFRuntime`,\n '@module-federation/sdk': `MFSDK`,\n }\n : {}\n const externals = {}\n for (const [key, value] of Object.entries(externalRuntime)) {\n externals[key] = `${this.rt.global}.${value}`\n }\n /**\n * TODO\n * 框架相关内容需要移除 share 由外部简化配置实现\n */\n if (this.fk.name === 'react' && !shareLib && this.fk.global) {\n const version = this.fk.version\n const externalReact = {\n react: `React`,\n 'react-dom': `ReactDOM`,\n }\n if (this.fk.entry === 'reactRouter') {\n externalReact['react-router-dom'] = 'ReactRouterDOM'\n }\n for (const [key, value] of Object.entries(externalReact)) {\n externals[key] = `${this.fk.global}.${value}`\n }\n if ([17, 18, 19].includes(version)) {\n externals['react-dom/client'] = this.fk.global\n externals['react/jsx-runtime'] = this.fk.global\n externals['react/jsx-dev-runtime'] = this.fk.global\n }\n }\n if (shareLib) {\n externalsLib.map(v => {\n if (v.type === 'js' && v.module && v.global) {\n externals[v.module] = `${this.fk.global}.${v.global}`\n }\n })\n }\n if (empRuntime.setExternals) empRuntime.setExternals(externals, this.fk.global, this.rt.global)\n //\n // console.log('externals in plugin', externals)\n store.chain.merge({externals})\n }\n private setRuntimeLib() {\n if (!this.op.empRuntime) return\n\n const {shareLib} = this.op.empRuntime\n const {store, injectHtml} = this\n const {empRuntime} = this.op\n if (!this.rt.lib) {\n // 内置 this.rt.lib\n store.chain.plugin('plugin-emp-share-framework').use(EmpShareRemoteLibPlugin, [empRuntime])\n }\n // 统一封装到 frameworkLib\n else if (this.rt.lib === 'useFrameworkLib' && !shareLib) {\n } else {\n // 插入 runtime\n injectHtml.push({tagName: 'script', pos: 'head', attributes: {src: this.rt.lib}})\n }\n }\n private setMfName() {\n if (this.op.name) {\n this.op.name = this.store.encodeVarName(this.op.name)\n if (this.op.name !== this.store.empConfig.output.uniqueName) {\n this.store.chain.output.set('uniqueName', this.op.name)\n }\n } else {\n this.op.name = this.store.empConfig.output.uniqueName\n }\n }\n private setMF() {\n const o = this.op\n const {store} = this\n if (o.name) {\n const op = store.deepAssign<ModuleFederationPluginOptions & {empRuntime: any}>(\n {\n filename: 'emp.js',\n manifest: false,\n dts: false,\n dev: {\n disableDynamicRemoteTypeHints: true,\n },\n },\n o,\n )\n //\n if (o.dev === false) op.dev = false\n //\n if (op.empRuntime) {\n delete op.empRuntime\n }\n store.chain.plugin('plugin-emp-share').use(ModuleFederationPlugin, [op])\n }\n }\n private setShareLib() {\n if (!this.op.empRuntime) return\n const {shareLib} = this.op.empRuntime\n const {externalsLib, injectHtml} = this\n if (shareLib && typeof shareLib === 'object') {\n for (const [k, v] of Object.entries(shareLib)) {\n let externalsItem: ExternalsItemType = {}\n externalsItem.module = k\n //增加下划线 支持lodash 等特殊符号的问题 如 _@http\n\n if (typeof v === 'string') {\n const cb: any = v.match(exp) || []\n if (cb.length > 0) {\n externalsItem.global = cb[1]\n externalsItem.entry = cb[2]\n externalsItem.type = 'js'\n externalsLib.push(externalsItem)\n externalsItem = {}\n } else {\n externalsItem.global = ''\n externalsItem.entry = v\n externalsItem.type = 'js'\n externalsLib.push(externalsItem)\n externalsItem = {}\n }\n } else if (Array.isArray(v)) {\n v.map(vo => {\n if (!vo) return\n const isCSS = vo.split('?')[0].endsWith('.css')\n if (isCSS) {\n externalsItem.entry = vo\n externalsItem.type = 'css'\n } else {\n const cb: any = vo.match(exp) || []\n if (cb.length > 0) {\n externalsItem.global = cb[1]\n externalsItem.entry = cb[2]\n externalsItem.type = 'js'\n } else {\n externalsItem.global = ''\n externalsItem.entry = vo\n externalsItem.type = 'js'\n }\n }\n externalsLib.push(externalsItem)\n externalsItem = {}\n })\n } else if (typeof v === 'object' && v.entry) {\n externalsItem.entry = v.entry\n externalsItem.global = v.global\n externalsItem.type = v.type\n externalsLib.push(externalsItem)\n externalsItem = {}\n }\n }\n // console.log(externalsLib)\n externalsLib.map(v => {\n if (v.type === 'js') {\n injectHtml.push({\n attributes: {\n src: v.entry,\n },\n tagName: 'script',\n })\n } else if (v.type === 'css') {\n injectHtml.push({\n attributes: {\n href: v.entry,\n rel: 'stylesheet',\n },\n tagName: 'link',\n })\n }\n })\n }\n }\n}\n","export const externalReact = (o: any, globalVal: string) => {\n o = Object.assign(o, {\n react: `${globalVal}.React`,\n 'react-dom': `${globalVal}.ReactDOM`,\n 'react-dom/client': globalVal,\n 'react/jsx-runtime': globalVal,\n 'react/jsx-dev-runtime': globalVal,\n 'react-router-dom': `${globalVal}.ReactRouterDOM`,\n })\n return o\n}\n","export const externalVue = (o: any, globalVal: string) => {\n o = Object.assign(o, {\n vue: `${globalVal}.Vue`,\n 'vue-router': `${globalVal}.VueRouter`,\n })\n return o\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,kBAAAC,EAAA,gBAAAC,EAAA,yBAAAC,IAAA,eAAAC,EAAAN,GCAO,IAAMO,EAAcC,GAAoB,wBAAwBA,CAAO,GAEvE,SAASC,EAAcC,KAAgBC,EAAiB,CAC7D,QAAWC,KAAUD,EACnB,QAAWE,KAAKD,EAAQ,CACtB,IAAME,EAAKF,EAAOC,CAAC,EACjBE,EAAKL,EAAOG,CAAC,EACf,GAAI,OAAOC,CAAE,GAAKA,GAAM,OAAOC,CAAE,IAAMA,EAAI,CACzCL,EAAOG,CAAC,EAAIJ,EAAWM,EAAID,CAAE,EAC7B,QACF,CACAJ,EAAOG,CAAC,EAAID,EAAOC,CAAC,CACtB,CAEF,OAAOH,CACT,CAMO,IAAMM,EAAQ,GACRC,EAAMD,EAAQ,QAAQ,IAAI,KAAK,QAAS,aAAa,EAAI,IAAM,CAAC,ECtBtE,IAAME,EAAkB,oBCA/B,IAAAC,EAAqC,8CCIrC,IAAMC,EAAuBC,GAAO,CAClC,IAAMC,EAAU,CAAC,WAAWD,CAAG,GAAG,EAAE,KAAK;AAAA,CAAI,EAC7C,OAAOE,EAAWD,CAAO,CAC3B,EAEaE,EAAN,KAA8B,CACnC,QACA,YAAYC,EAA4B,CACtC,KAAK,QAAUA,CACjB,CACA,MAAMC,EAAoB,CACxB,GAAM,CAAC,QAAAC,CAAO,EAAID,EACZE,EAAQR,EAAqB,sBAAs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,KAAOJ,EAAE,KACvBR,EAAa,KAAKY,CAAa,EAC/BA,EAAgB,CAAC,EAErB,CAEAZ,EAAa,IAAIQ,GAAK,CAChBA,EAAE,OAAS,KACbrB,EAAW,KAAK,CACd,WAAY,CACV,IAAKqB,EAAE,KACT,EACA,QAAS,QACX,CAAC,EACQA,EAAE,OAAS,OACpBrB,EAAW,KAAK,CACd,WAAY,CACV,KAAMqB,EAAE,MACR,IAAK,YACP,EACA,QAAS,MACX,CAAC,CAEL,CAAC,CACH,CACF,CACF,ECxTO,IAAMO,EAAgB,CAACC,EAAQC,KACpCD,EAAI,OAAO,OAAOA,EAAG,CACnB,MAAO,GAAGC,CAAS,SACnB,YAAa,GAAGA,CAAS,YACzB,mBAAoBA,EACpB,oBAAqBA,EACrB,wBAAyBA,EACzB,mBAAoB,GAAGA,CAAS,iBAClC,CAAC,EACMD,GCTF,IAAME,EAAc,CAACC,EAAQC,KAClCD,EAAI,OAAO,OAAOA,EAAG,CACnB,IAAK,GAAGC,CAAS,OACjB,aAAc,GAAGA,CAAS,YAC5B,CAAC,EACMD,GRGF,IAAME,EAAuB,CAACC,EAAwB,CAAC,KACrD,CACL,KAAM,eACN,MAAM,SAASC,EAAoB,CAE7BD,EAAE,WAAa,GACjBA,EAAE,SAAW,CACX,SAAU,UACZ,EACS,OAAOA,EAAE,UAAa,WAC/BA,EAAE,SAAWC,EAAM,WAAW,CAAC,SAAU,UAAU,EAAGD,EAAE,QAAQ,GAEjD,IAAIE,EAASF,EAAGC,CAAK,EAC7B,MAAM,CACjB,CACF,GAEKE,EAAQJ","names":["rspack_exports","__export","rspack_default","externalReact","externalVue","pluginRspackEmpShare","__toCommonJS","importJsVm","content","deepAssign","target","sources","source","k","vs","vt","isDev","log","shareGlobalName","import_rspack","getShareRuntimeEntry","url","content","importJsVm","EmpShareRemoteLibPlugin","op","compiler","webpack","entry","getRuntimeLib","host","mode","entry","exp","EmpShare","op","store","injectHtml","url","getRuntimeLib","libs","empRuntime","frameworkGlobal","injectData","framework","frameworkLib","deepAssign","global","shareGlobalName","lib","externalsLib","shareLib","externalRuntime","externals","key","value","version","externalReact","v","EmpShareRemoteLibPlugin","o","k","externalsItem","cb","vo","externalReact","o","globalVal","externalVue","o","globalVal","pluginRspackEmpShare","o","store","EmpShare","rspack_default"]}
|