@hitachivantara/app-shell-vite-plugin 0.5.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/LICENSE +201 -0
- package/README.md +60 -0
- package/dist/esm-externals/react-dom.production.min.js +12 -0
- package/dist/esm-externals/react-dom.production.min.js.map +1 -0
- package/dist/esm-externals/react-router-dom.production.min.js +33 -0
- package/dist/esm-externals/react-router-dom.production.min.js.map +1 -0
- package/dist/esm-externals/react.production.min.js +3 -0
- package/dist/esm-externals/react.production.min.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/vite-importmap-plugin.d.ts +8 -0
- package/dist/vite-importmap-plugin.d.ts.map +1 -0
- package/dist/vite-importmap-plugin.js +170 -0
- package/dist/vite-importmap-plugin.js.map +1 -0
- package/dist/vite-plugin.d.ts +27 -0
- package/dist/vite-plugin.d.ts.map +1 -0
- package/dist/vite-plugin.js +352 -0
- package/dist/vite-plugin.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/* @preserve react (18.2.0) esm bundle generated by Hitachi Vantara - Boba Fett team */
|
|
2
|
+
function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var t,r={},n={};function o(){if(t)return n;t=1;var e=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),u=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),f=Symbol.for("react.context"),i=Symbol.for("react.forward_ref"),s=Symbol.for("react.suspense"),l=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),y=Symbol.iterator;var d={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},m=Object.assign,_={};function h(e,t,r){this.props=e,this.context=t,this.refs=_,this.updater=r||d}function v(){}function b(e,t,r){this.props=e,this.context=t,this.refs=_,this.updater=r||d}h.prototype.isReactComponent={},h.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},h.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},v.prototype=h.prototype;var S=b.prototype=new v;S.constructor=b,m(S,h.prototype),S.isPureReactComponent=!0;var E=Array.isArray,R=Object.prototype.hasOwnProperty,C={current:null},w={key:!0,ref:!0,__self:!0,__source:!0};function $(t,r,n){var o,u={},a=null,c=null;if(null!=r)for(o in void 0!==r.ref&&(c=r.ref),void 0!==r.key&&(a=""+r.key),r)R.call(r,o)&&!w.hasOwnProperty(o)&&(u[o]=r[o]);var f=arguments.length-2;if(1===f)u.children=n;else if(1<f){for(var i=Array(f),s=0;s<f;s++)i[s]=arguments[s+2];u.children=i}if(t&&t.defaultProps)for(o in f=t.defaultProps)void 0===u[o]&&(u[o]=f[o]);return{$$typeof:e,type:t,key:a,ref:c,props:u,_owner:C.current}}function k(t){return"object"==typeof t&&null!==t&&t.$$typeof===e}var g=/\/+/g;function j(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}(""+e.key):t.toString(36)}function x(t,n,o,u,a){var c=typeof t;"undefined"!==c&&"boolean"!==c||(t=null);var f=!1;if(null===t)f=!0;else switch(c){case"string":case"number":f=!0;break;case"object":switch(t.$$typeof){case e:case r:f=!0}}if(f)return a=a(f=t),t=""===u?"."+j(f,0):u,E(a)?(o="",null!=t&&(o=t.replace(g,"$&/")+"/"),x(a,n,o,"",(function(e){return e}))):null!=a&&(k(a)&&(a=function(t,r){return{$$typeof:e,type:t.type,key:r,ref:t.ref,props:t.props,_owner:t._owner}}(a,o+(!a.key||f&&f.key===a.key?"":(""+a.key).replace(g,"$&/")+"/")+t)),n.push(a)),1;if(f=0,u=""===u?".":u+":",E(t))for(var i=0;i<t.length;i++){var s=u+j(c=t[i],i);f+=x(c,n,o,s,a)}else if(s=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=y&&e[y]||e["@@iterator"])?e:null}(t),"function"==typeof s)for(t=s.call(t),i=0;!(c=t.next()).done;)f+=x(c=c.value,n,o,s=u+j(c,i++),a);else if("object"===c)throw n=String(t),Error("Objects are not valid as a React child (found: "+("[object Object]"===n?"object with keys {"+Object.keys(t).join(", ")+"}":n)+"). If you meant to render a collection of children, use an array instead.");return f}function O(e,t,r){if(null==e)return e;var n=[],o=0;return x(e,n,"","",(function(e){return t.call(r,e,o++)})),n}function P(e){if(-1===e._status){var t=e._result;(t=t()).then((function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)}),(function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)})),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var I={current:null},V={transition:null},D={ReactCurrentDispatcher:I,ReactCurrentBatchConfig:V,ReactCurrentOwner:C};return n.Children={map:O,forEach:function(e,t,r){O(e,(function(){t.apply(this,arguments)}),r)},count:function(e){var t=0;return O(e,(function(){t++})),t},toArray:function(e){return O(e,(function(e){return e}))||[]},only:function(e){if(!k(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},n.Component=h,n.Fragment=o,n.Profiler=a,n.PureComponent=b,n.StrictMode=u,n.Suspense=s,n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=D,n.cloneElement=function(t,r,n){if(null==t)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+t+".");var o=m({},t.props),u=t.key,a=t.ref,c=t._owner;if(null!=r){if(void 0!==r.ref&&(a=r.ref,c=C.current),void 0!==r.key&&(u=""+r.key),t.type&&t.type.defaultProps)var f=t.type.defaultProps;for(i in r)R.call(r,i)&&!w.hasOwnProperty(i)&&(o[i]=void 0===r[i]&&void 0!==f?f[i]:r[i])}var i=arguments.length-2;if(1===i)o.children=n;else if(1<i){f=Array(i);for(var s=0;s<i;s++)f[s]=arguments[s+2];o.children=f}return{$$typeof:e,type:t.type,key:u,ref:a,props:o,_owner:c}},n.createContext=function(e){return(e={$$typeof:f,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:c,_context:e},e.Consumer=e},n.createElement=$,n.createFactory=function(e){var t=$.bind(null,e);return t.type=e,t},n.createRef=function(){return{current:null}},n.forwardRef=function(e){return{$$typeof:i,render:e}},n.isValidElement=k,n.lazy=function(e){return{$$typeof:p,_payload:{_status:-1,_result:e},_init:P}},n.memo=function(e,t){return{$$typeof:l,type:e,compare:void 0===t?null:t}},n.startTransition=function(e){var t=V.transition;V.transition={};try{e()}finally{V.transition=t}},n.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.")},n.useCallback=function(e,t){return I.current.useCallback(e,t)},n.useContext=function(e){return I.current.useContext(e)},n.useDebugValue=function(){},n.useDeferredValue=function(e){return I.current.useDeferredValue(e)},n.useEffect=function(e,t){return I.current.useEffect(e,t)},n.useId=function(){return I.current.useId()},n.useImperativeHandle=function(e,t,r){return I.current.useImperativeHandle(e,t,r)},n.useInsertionEffect=function(e,t){return I.current.useInsertionEffect(e,t)},n.useLayoutEffect=function(e,t){return I.current.useLayoutEffect(e,t)},n.useMemo=function(e,t){return I.current.useMemo(e,t)},n.useReducer=function(e,t,r){return I.current.useReducer(e,t,r)},n.useRef=function(e){return I.current.useRef(e)},n.useState=function(e){return I.current.useState(e)},n.useSyncExternalStore=function(e,t,r){return I.current.useSyncExternalStore(e,t,r)},n.useTransition=function(){return I.current.useTransition()},n.version="18.2.0",n}({get exports(){return r},set exports(e){r=e}}).exports=o();var u=e(r);const a=!0,{Fragment:c,StrictMode:f,Profiler:i,Suspense:s,Children:l,Component:p,PureComponent:y,cloneElement:d,createContext:m,createElement:_,createFactory:h,createRef:v,forwardRef:b,isValidElement:S,lazy:E,memo:R,useCallback:C,useContext:w,useDebugValue:$,useEffect:k,useImperativeHandle:g,useLayoutEffect:j,useMemo:x,useReducer:O,useRef:P,useState:I,version:V}=u;export{l as Children,p as Component,c as Fragment,i as Profiler,y as PureComponent,f as StrictMode,s as Suspense,a as __esmModule,d as cloneElement,m as createContext,_ as createElement,h as createFactory,v as createRef,u as default,b as forwardRef,S as isValidElement,E as lazy,R as memo,C as useCallback,w as useContext,$ as useDebugValue,k as useEffect,g as useImperativeHandle,j as useLayoutEffect,x as useMemo,O as useReducer,P as useRef,I as useState,V as version};
|
|
3
|
+
//# sourceMappingURL=react.production.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.production.min.js","sources":["../../../../node_modules/react/cjs/react.production.min.js","../../../../node_modules/react/index.js","../../src/export-externals/exportReact.js"],"sourcesContent":["/**\n * @license React\n * react.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var l=Symbol.for(\"react.element\"),n=Symbol.for(\"react.portal\"),p=Symbol.for(\"react.fragment\"),q=Symbol.for(\"react.strict_mode\"),r=Symbol.for(\"react.profiler\"),t=Symbol.for(\"react.provider\"),u=Symbol.for(\"react.context\"),v=Symbol.for(\"react.forward_ref\"),w=Symbol.for(\"react.suspense\"),x=Symbol.for(\"react.memo\"),y=Symbol.for(\"react.lazy\"),z=Symbol.iterator;function A(a){if(null===a||\"object\"!==typeof a)return null;a=z&&a[z]||a[\"@@iterator\"];return\"function\"===typeof a?a:null}\nvar B={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,D={};function E(a,b,e){this.props=a;this.context=b;this.refs=D;this.updater=e||B}E.prototype.isReactComponent={};\nE.prototype.setState=function(a,b){if(\"object\"!==typeof a&&\"function\"!==typeof a&&null!=a)throw Error(\"setState(...): takes an object of state variables to update or a function which returns an object of state variables.\");this.updater.enqueueSetState(this,a,b,\"setState\")};E.prototype.forceUpdate=function(a){this.updater.enqueueForceUpdate(this,a,\"forceUpdate\")};function F(){}F.prototype=E.prototype;function G(a,b,e){this.props=a;this.context=b;this.refs=D;this.updater=e||B}var H=G.prototype=new F;\nH.constructor=G;C(H,E.prototype);H.isPureReactComponent=!0;var I=Array.isArray,J=Object.prototype.hasOwnProperty,K={current:null},L={key:!0,ref:!0,__self:!0,__source:!0};\nfunction M(a,b,e){var d,c={},k=null,h=null;if(null!=b)for(d in void 0!==b.ref&&(h=b.ref),void 0!==b.key&&(k=\"\"+b.key),b)J.call(b,d)&&!L.hasOwnProperty(d)&&(c[d]=b[d]);var g=arguments.length-2;if(1===g)c.children=e;else if(1<g){for(var f=Array(g),m=0;m<g;m++)f[m]=arguments[m+2];c.children=f}if(a&&a.defaultProps)for(d in g=a.defaultProps,g)void 0===c[d]&&(c[d]=g[d]);return{$$typeof:l,type:a,key:k,ref:h,props:c,_owner:K.current}}\nfunction N(a,b){return{$$typeof:l,type:a.type,key:b,ref:a.ref,props:a.props,_owner:a._owner}}function O(a){return\"object\"===typeof a&&null!==a&&a.$$typeof===l}function escape(a){var b={\"=\":\"=0\",\":\":\"=2\"};return\"$\"+a.replace(/[=:]/g,function(a){return b[a]})}var P=/\\/+/g;function Q(a,b){return\"object\"===typeof a&&null!==a&&null!=a.key?escape(\"\"+a.key):b.toString(36)}\nfunction R(a,b,e,d,c){var k=typeof a;if(\"undefined\"===k||\"boolean\"===k)a=null;var h=!1;if(null===a)h=!0;else switch(k){case \"string\":case \"number\":h=!0;break;case \"object\":switch(a.$$typeof){case l:case n:h=!0}}if(h)return h=a,c=c(h),a=\"\"===d?\".\"+Q(h,0):d,I(c)?(e=\"\",null!=a&&(e=a.replace(P,\"$&/\")+\"/\"),R(c,b,e,\"\",function(a){return a})):null!=c&&(O(c)&&(c=N(c,e+(!c.key||h&&h.key===c.key?\"\":(\"\"+c.key).replace(P,\"$&/\")+\"/\")+a)),b.push(c)),1;h=0;d=\"\"===d?\".\":d+\":\";if(I(a))for(var g=0;g<a.length;g++){k=\na[g];var f=d+Q(k,g);h+=R(k,b,e,f,c)}else if(f=A(a),\"function\"===typeof f)for(a=f.call(a),g=0;!(k=a.next()).done;)k=k.value,f=d+Q(k,g++),h+=R(k,b,e,f,c);else if(\"object\"===k)throw b=String(a),Error(\"Objects are not valid as a React child (found: \"+(\"[object Object]\"===b?\"object with keys {\"+Object.keys(a).join(\", \")+\"}\":b)+\"). If you meant to render a collection of children, use an array instead.\");return h}\nfunction S(a,b,e){if(null==a)return a;var d=[],c=0;R(a,d,\"\",\"\",function(a){return b.call(e,a,c++)});return d}function T(a){if(-1===a._status){var b=a._result;b=b();b.then(function(b){if(0===a._status||-1===a._status)a._status=1,a._result=b},function(b){if(0===a._status||-1===a._status)a._status=2,a._result=b});-1===a._status&&(a._status=0,a._result=b)}if(1===a._status)return a._result.default;throw a._result;}\nvar U={current:null},V={transition:null},W={ReactCurrentDispatcher:U,ReactCurrentBatchConfig:V,ReactCurrentOwner:K};exports.Children={map:S,forEach:function(a,b,e){S(a,function(){b.apply(this,arguments)},e)},count:function(a){var b=0;S(a,function(){b++});return b},toArray:function(a){return S(a,function(a){return a})||[]},only:function(a){if(!O(a))throw Error(\"React.Children.only expected to receive a single React element child.\");return a}};exports.Component=E;exports.Fragment=p;\nexports.Profiler=r;exports.PureComponent=G;exports.StrictMode=q;exports.Suspense=w;exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=W;\nexports.cloneElement=function(a,b,e){if(null===a||void 0===a)throw Error(\"React.cloneElement(...): The argument must be a React element, but you passed \"+a+\".\");var d=C({},a.props),c=a.key,k=a.ref,h=a._owner;if(null!=b){void 0!==b.ref&&(k=b.ref,h=K.current);void 0!==b.key&&(c=\"\"+b.key);if(a.type&&a.type.defaultProps)var g=a.type.defaultProps;for(f in b)J.call(b,f)&&!L.hasOwnProperty(f)&&(d[f]=void 0===b[f]&&void 0!==g?g[f]:b[f])}var f=arguments.length-2;if(1===f)d.children=e;else if(1<f){g=Array(f);\nfor(var m=0;m<f;m++)g[m]=arguments[m+2];d.children=g}return{$$typeof:l,type:a.type,key:c,ref:k,props:d,_owner:h}};exports.createContext=function(a){a={$$typeof:u,_currentValue:a,_currentValue2:a,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null};a.Provider={$$typeof:t,_context:a};return a.Consumer=a};exports.createElement=M;exports.createFactory=function(a){var b=M.bind(null,a);b.type=a;return b};exports.createRef=function(){return{current:null}};\nexports.forwardRef=function(a){return{$$typeof:v,render:a}};exports.isValidElement=O;exports.lazy=function(a){return{$$typeof:y,_payload:{_status:-1,_result:a},_init:T}};exports.memo=function(a,b){return{$$typeof:x,type:a,compare:void 0===b?null:b}};exports.startTransition=function(a){var b=V.transition;V.transition={};try{a()}finally{V.transition=b}};exports.unstable_act=function(){throw Error(\"act(...) is not supported in production builds of React.\");};\nexports.useCallback=function(a,b){return U.current.useCallback(a,b)};exports.useContext=function(a){return U.current.useContext(a)};exports.useDebugValue=function(){};exports.useDeferredValue=function(a){return U.current.useDeferredValue(a)};exports.useEffect=function(a,b){return U.current.useEffect(a,b)};exports.useId=function(){return U.current.useId()};exports.useImperativeHandle=function(a,b,e){return U.current.useImperativeHandle(a,b,e)};\nexports.useInsertionEffect=function(a,b){return U.current.useInsertionEffect(a,b)};exports.useLayoutEffect=function(a,b){return U.current.useLayoutEffect(a,b)};exports.useMemo=function(a,b){return U.current.useMemo(a,b)};exports.useReducer=function(a,b,e){return U.current.useReducer(a,b,e)};exports.useRef=function(a){return U.current.useRef(a)};exports.useState=function(a){return U.current.useState(a)};exports.useSyncExternalStore=function(a,b,e){return U.current.useSyncExternalStore(a,b,e)};\nexports.useTransition=function(){return U.current.useTransition()};exports.version=\"18.2.0\";\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react.production.min.js');\n} else {\n module.exports = require('./cjs/react.development.js');\n}\n","import React from \"react\";\n\nexport default React;\n/* eslint no-underscore-dangle: \"off\" */\nexport const __esmModule = true;\nexport const {\n Fragment,\n StrictMode,\n Profiler,\n Suspense,\n Children,\n Component,\n PureComponent,\n cloneElement,\n createContext,\n createElement,\n createFactory,\n createRef,\n forwardRef,\n isValidElement,\n lazy,\n memo,\n useCallback,\n useContext,\n useDebugValue,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useReducer,\n useRef,\n useState,\n version\n} = React;\n"],"names":["l","Symbol","for","n","p","q","r","t","u","v","w","x","y","z","iterator","B","isMounted","enqueueForceUpdate","enqueueReplaceState","enqueueSetState","C","Object","assign","D","E","a","b","e","this","props","context","refs","updater","F","G","prototype","isReactComponent","setState","Error","forceUpdate","H","constructor","isPureReactComponent","I","Array","isArray","J","hasOwnProperty","K","current","L","key","ref","__self","__source","M","d","c","k","h","call","g","arguments","length","children","f","m","defaultProps","$$typeof","type","_owner","O","P","Q","replace","escape","toString","R","N","push","A","next","done","value","String","keys","join","S","T","_status","_result","then","default","U","V","transition","W","ReactCurrentDispatcher","ReactCurrentBatchConfig","ReactCurrentOwner","react_production_min","Children","map","forEach","apply","count","toArray","only","Component","Fragment","Profiler","StrictMode","__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED","cloneElement","createContext","_currentValue","_currentValue2","_threadCount","Provider","Consumer","_defaultValue","_globalName","_context","createElement","bind","createRef","forwardRef","render","isValidElement","lazy","_payload","_init","memo","compare","startTransition","unstable_act","useCallback","useContext","useDebugValue","useDeferredValue","useEffect","useId","useImperativeHandle","useInsertionEffect","useLayoutEffect","useMemo","useReducer","useRef","useState","useSyncExternalStore","useTransition","version","exports","require$$0","__esmModule","Suspense","PureComponent","createFactory","React"],"mappings":";mJASa,IAAIA,EAAEC,OAAOC,IAAI,iBAAiBC,EAAEF,OAAOC,IAAI,gBAAgBE,EAAEH,OAAOC,IAAI,kBAAkBG,EAAEJ,OAAOC,IAAI,qBAAqBI,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H,EAAE,EAAE2E,EAA4BiD,qBAAC,SAAS5H,EAAEC,EAAEC,GAAG,OAAOkE,EAAE5C,QAAQoG,qBAAqB5H,EAAEC,EAAEC,EAAE,EAC/eyE,EAAAkD,cAAsB,WAAW,OAAOzD,EAAE5C,QAAQqG,eAAe,EAAElD,EAAAmD,QAAgB,2DCtBjFC,QAAiBC,eCCP,MAACC,GAAc,GACd7C,SACXA,EAAQE,WACRA,EAAUD,SACVA,EAAQ6C,SACRA,EAAQtD,SACRA,EAAQO,UACRA,EAASgD,cACTA,EAAa3C,aACbA,EAAYC,cACZA,EAAaS,cACbA,EAAakC,cACbA,EAAahC,UACbA,EAASC,WACTA,EAAUE,eACVA,EAAcC,KACdA,EAAIG,KACJA,EAAII,YACJA,EAAWC,WACXA,EAAUC,cACVA,EAAaE,UACbA,EAASE,oBACTA,EAAmBE,gBACnBA,EAAeC,QACfA,EAAOC,WACPA,EAAUC,OACVA,EAAMC,SACNA,EAAQG,QACRA,GACEO","x_google_ignoreList":[0,1]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAEnE,cAAc,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAEnE,cAAc,kBAAkB,CAAC","sourcesContent":["export { default as HvAppShellVitePlugin } from \"./vite-plugin.js\";\n\nexport * from \"./vite-plugin.js\";\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PluginOption } from "vite";
|
|
2
|
+
/**
|
|
3
|
+
* Generate and injects the importmap tag into index.html
|
|
4
|
+
* @param importmapElements The importmap elements to be included
|
|
5
|
+
* @param sharedDependencies The shared packages (other than application bundles)
|
|
6
|
+
*/
|
|
7
|
+
export default function generateImportmap(importmapElements: Record<string, string>, sharedDependencies: string[], externalImportMap?: boolean): PluginOption;
|
|
8
|
+
//# sourceMappingURL=vite-importmap-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-importmap-plugin.d.ts","sourceRoot":"","sources":["../src/vite-importmap-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAiCpC;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACzC,kBAAkB,EAAE,MAAM,EAAE,EAC5B,iBAAiB,UAAQ,GACxB,YAAY,CAiLd"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import virtual from "@rollup/plugin-virtual";
|
|
4
|
+
const ID_PREFIX = `/@id/`;
|
|
5
|
+
function replaceIdPrefix(keys) {
|
|
6
|
+
const reg = new RegExp(`${ID_PREFIX}(${keys.join("|")})`, "g");
|
|
7
|
+
return {
|
|
8
|
+
name: "vite-plugin-importmap-replace-idprefix",
|
|
9
|
+
enforce: "pre",
|
|
10
|
+
apply: "serve",
|
|
11
|
+
// while in dev, we need to prevent 'vite:import-analysis' on runtime modules
|
|
12
|
+
transform: code => reg.test(code) ? code.replace(reg, (m, s1) => s1) : code,
|
|
13
|
+
// and to say its resolved (as external)
|
|
14
|
+
resolveId: (id) => keys.some(key => typeof key === "string" ? id.startsWith(key) : key.test(id))
|
|
15
|
+
? {
|
|
16
|
+
id,
|
|
17
|
+
external: true
|
|
18
|
+
}
|
|
19
|
+
: undefined
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Generate and injects the importmap tag into index.html
|
|
24
|
+
* @param importmapElements The importmap elements to be included
|
|
25
|
+
* @param sharedDependencies The shared packages (other than application bundles)
|
|
26
|
+
*/
|
|
27
|
+
export default function generateImportmap(importmapElements, sharedDependencies, externalImportMap = false) {
|
|
28
|
+
const keys = Object.keys(importmapElements);
|
|
29
|
+
const devKeys = keys.filter(key => !sharedDependencies.some(lib => lib.startsWith(key)));
|
|
30
|
+
let devMode = false;
|
|
31
|
+
const importmapString = JSON.stringify({ imports: importmapElements }, null, 2);
|
|
32
|
+
const importmapScript = `const im = document.createElement('script');
|
|
33
|
+
im.type = 'importmap';
|
|
34
|
+
im.textContent = \`${importmapString}\`;
|
|
35
|
+
document.currentScript.after(im);
|
|
36
|
+
`;
|
|
37
|
+
return [
|
|
38
|
+
{
|
|
39
|
+
name: "vite-plugin-importmap",
|
|
40
|
+
enforce: "pre",
|
|
41
|
+
// don't optimize / pre-transform deps that are in the importmap
|
|
42
|
+
// except for react and react-dom when in dev mode
|
|
43
|
+
config(config, { command }) {
|
|
44
|
+
devMode = command !== "build";
|
|
45
|
+
// vite docs says we can mutate the passed-in config directly
|
|
46
|
+
// assigning to a new variable just to avoid the eslint warning
|
|
47
|
+
const returnValue = config;
|
|
48
|
+
// make sure optimizeDeps is defined
|
|
49
|
+
returnValue.optimizeDeps = returnValue.optimizeDeps ?? {};
|
|
50
|
+
returnValue.optimizeDeps.exclude = [
|
|
51
|
+
...(config.optimizeDeps?.exclude ?? []),
|
|
52
|
+
...(devMode ? devKeys : keys)
|
|
53
|
+
];
|
|
54
|
+
if (devMode) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
// mark the modules referenced in the importmap as external
|
|
58
|
+
const excludedModules = keys.map(key => {
|
|
59
|
+
if (key.endsWith("/")) {
|
|
60
|
+
return new RegExp(`^${key}.*`);
|
|
61
|
+
}
|
|
62
|
+
return key;
|
|
63
|
+
});
|
|
64
|
+
console.info("Shared packages marked as external: ", excludedModules);
|
|
65
|
+
// make sure build's rollupOptions is defined
|
|
66
|
+
returnValue.build = returnValue.build ?? {};
|
|
67
|
+
returnValue.build.rollupOptions = returnValue.build.rollupOptions ?? {};
|
|
68
|
+
returnValue.build.rollupOptions.external =
|
|
69
|
+
returnValue.build.rollupOptions.external ?? [];
|
|
70
|
+
if (typeof returnValue.build.rollupOptions.external === "function") {
|
|
71
|
+
// in case the developer has defined a custom external function
|
|
72
|
+
// we wrap it and check our excluded modules first and call the original function if needed
|
|
73
|
+
const originalExternal = returnValue.build.rollupOptions.external;
|
|
74
|
+
returnValue.build.rollupOptions.external = (id, ...args) => {
|
|
75
|
+
if (excludedModules.some(m => typeof m === id)) {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
return originalExternal(id, ...args);
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
// otherwise we just add our excluded modules to the list supplied by the developer
|
|
83
|
+
const externalModules = [];
|
|
84
|
+
if (Array.isArray(returnValue.build.rollupOptions.external)) {
|
|
85
|
+
externalModules.push(...returnValue.build.rollupOptions.external);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
externalModules.push(returnValue.build.rollupOptions.external);
|
|
89
|
+
}
|
|
90
|
+
externalModules.push(...excludedModules);
|
|
91
|
+
returnValue.build.rollupOptions.external = externalModules;
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
// while in dev, we need to prevent 'vite:import-analysis' on runtime modules
|
|
95
|
+
// and also to say they're resolved (as external)
|
|
96
|
+
// (it will still output an error in the console, but it won't break)
|
|
97
|
+
// known issue: https://github.com/vitejs/vite/issues/11633
|
|
98
|
+
configResolved(resolvedConfig) {
|
|
99
|
+
if (!devMode) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
103
|
+
// @ts-ignore an hack: we want to add the plugin only after the config is resolved
|
|
104
|
+
resolvedConfig.plugins.push(replaceIdPrefix(devKeys));
|
|
105
|
+
},
|
|
106
|
+
/**
|
|
107
|
+
* Rollup hook with the info for bundle generation
|
|
108
|
+
* It will be used to create a new configuration with:
|
|
109
|
+
* - bundles replace with the final location (e.g. -> "bundle": "src/pages/Main" transformed to "bundle": "pages/Main.js",
|
|
110
|
+
* @param options build options
|
|
111
|
+
* @param bundle bundles information
|
|
112
|
+
*/
|
|
113
|
+
async generateBundle(options) {
|
|
114
|
+
if (!externalImportMap) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
// obtain the directory (dist) where the new config file will be placed
|
|
118
|
+
let targetDir;
|
|
119
|
+
if (options.dir) {
|
|
120
|
+
targetDir = options.dir;
|
|
121
|
+
}
|
|
122
|
+
else if (options.file) {
|
|
123
|
+
targetDir = path.dirname(options.file);
|
|
124
|
+
}
|
|
125
|
+
if (!targetDir) {
|
|
126
|
+
throw new Error("Please set outputPath, so we can know where to place the json file");
|
|
127
|
+
}
|
|
128
|
+
// create the targetDir if it does not exist
|
|
129
|
+
if (!fs.existsSync(targetDir)) {
|
|
130
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
131
|
+
}
|
|
132
|
+
// support for external import maps isn't yet available (https://github.com/WICG/import-maps/issues/235)
|
|
133
|
+
// workaround: https://github.com/WICG/import-maps/issues/235#issuecomment-1002340944
|
|
134
|
+
fs.writeFileSync(path.resolve(targetDir, "importmap.js"), importmapScript);
|
|
135
|
+
},
|
|
136
|
+
// inject the importmap script and also the es-module-shims script
|
|
137
|
+
transformIndexHtml: {
|
|
138
|
+
enforce: "post",
|
|
139
|
+
transform: html => ({
|
|
140
|
+
html,
|
|
141
|
+
tags: [
|
|
142
|
+
{
|
|
143
|
+
tag: "script",
|
|
144
|
+
attrs: { async: true, src: "./bundles/es-module-shims.js" },
|
|
145
|
+
injectTo: "head-prepend"
|
|
146
|
+
},
|
|
147
|
+
externalImportMap
|
|
148
|
+
? {
|
|
149
|
+
tag: "script",
|
|
150
|
+
attrs: { src: "./importmap.js" },
|
|
151
|
+
injectTo: "head-prepend"
|
|
152
|
+
}
|
|
153
|
+
: {
|
|
154
|
+
tag: "script",
|
|
155
|
+
attrs: { type: "importmap" },
|
|
156
|
+
injectTo: "head-prepend",
|
|
157
|
+
children: importmapString
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
})
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
externalImportMap
|
|
164
|
+
? virtual({
|
|
165
|
+
"/importmap.js": importmapScript
|
|
166
|
+
})
|
|
167
|
+
: false
|
|
168
|
+
];
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=vite-importmap-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-importmap-plugin.js","sourceRoot":"","sources":["../src/vite-importmap-plugin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAE7C,MAAM,SAAS,GAAG,OAAO,CAAC;AAE1B,SAAS,eAAe,CAAC,IAAyB;IAChD,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,GAAG,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAE/D,OAAO;QACL,IAAI,EAAE,wCAAwC;QAC9C,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,OAAO;QAEd,6EAA6E;QAC7E,SAAS,EAAE,IAAI,CAAC,EAAE,CAChB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI;QAE1D,wCAAwC;QACxC,SAAS,EAAE,CAAC,EAAU,EAAE,EAAE,CACxB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,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KAAK,CACb,oEAAoE,CACrE,CAAC;iBACH;gBAED,4CAA4C;gBAC5C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;oBAC7B,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;iBAC9C;gBAED,wGAAwG;gBACxG,qFAAqF;gBACrF,EAAE,CAAC,aAAa,CACd,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,cAAc,CAAC,EACvC,eAAe,CAChB,CAAC;YACJ,CAAC;YAED,kEAAkE;YAClE,kBAAkB,EAAE;gBAClB,OAAO,EAAE,MAAM;gBACf,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;oBAClB,IAAI;oBACJ,IAAI,EAAE;wBACJ;4BACE,GAAG,EAAE,QAAQ;4BACb,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,8BAA8B,EAAE;4BAC3D,QAAQ,EAAE,cAAc;yBACzB;wBACD,iBAAiB;4BACf,CAAC,CAAC;gCACE,GAAG,EAAE,QAAQ;gCACb,KAAK,EAAE,EAAE,GAAG,EAAE,gBAAgB,EAAE;gCAChC,QAAQ,EAAE,cAAc;6BACzB;4BACH,CAAC,CAAC;gCACE,GAAG,EAAE,QAAQ;gCACb,KAAK,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE;gCAC5B,QAAQ,EAAE,cAAc;gCACxB,QAAQ,EAAE,eAAe;6BAC1B;qBACN;iBACF,CAAC;aACH;SACF;QACD,iBAAiB;YACf,CAAC,CAAC,OAAO,CAAC;gBACN,eAAe,EAAE,eAAe;aACjC,CAAC;YACJ,CAAC,CAAC,KAAK;KACV,CAAC;AACJ,CAAC","sourcesContent":["import { NormalizedOutputOptions } from \"rollup\";\nimport { PluginOption } from \"vite\";\n\nimport fs from \"fs\";\nimport path from \"path\";\nimport virtual from \"@rollup/plugin-virtual\";\n\nconst ID_PREFIX = `/@id/`;\n\nfunction replaceIdPrefix(keys: (string | RegExp)[]): PluginOption {\n const reg = new RegExp(`${ID_PREFIX}(${keys.join(\"|\")})`, \"g\");\n\n return {\n name: \"vite-plugin-importmap-replace-idprefix\",\n enforce: \"pre\",\n apply: \"serve\",\n\n // while in dev, we need to prevent 'vite:import-analysis' on runtime modules\n transform: code =>\n reg.test(code) ? code.replace(reg, (m, s1) => s1) : code,\n\n // and to say its resolved (as external)\n resolveId: (id: string) =>\n keys.some(key =>\n typeof key === \"string\" ? id.startsWith(key) : key.test(id)\n )\n ? {\n id,\n external: true\n }\n : undefined\n };\n}\n\n/**\n * Generate and injects the importmap tag into index.html\n * @param importmapElements The importmap elements to be included\n * @param sharedDependencies The shared packages (other than application bundles)\n */\nexport default function generateImportmap(\n importmapElements: Record<string, string>,\n sharedDependencies: string[],\n externalImportMap = false\n): PluginOption {\n const keys = Object.keys(importmapElements);\n const devKeys = keys.filter(\n key => !sharedDependencies.some(lib => lib.startsWith(key))\n );\n\n let devMode = false;\n\n const importmapString = JSON.stringify(\n { imports: importmapElements },\n null,\n 2\n );\n\n const importmapScript = `const im = document.createElement('script');\nim.type = 'importmap';\nim.textContent = \\`${importmapString}\\`;\ndocument.currentScript.after(im);\n`;\n\n return [\n {\n name: \"vite-plugin-importmap\",\n enforce: \"pre\",\n\n // don't optimize / pre-transform deps that are in the importmap\n // except for react and react-dom when in dev mode\n config(config, { command }) {\n devMode = command !== \"build\";\n\n // vite docs says we can mutate the passed-in config directly\n // assigning to a new variable just to avoid the eslint warning\n const returnValue = config;\n\n // make sure optimizeDeps is defined\n returnValue.optimizeDeps = returnValue.optimizeDeps ?? {};\n\n returnValue.optimizeDeps.exclude = [\n ...(config.optimizeDeps?.exclude ?? []),\n ...(devMode ? devKeys : keys)\n ];\n\n if (devMode) {\n return;\n }\n\n // mark the modules referenced in the importmap as external\n const excludedModules = keys.map(key => {\n if (key.endsWith(\"/\")) {\n return new RegExp(`^${key}.*`);\n }\n\n return key;\n });\n\n console.info(\"Shared packages marked as external: \", excludedModules);\n\n // make sure build's rollupOptions is defined\n returnValue.build = returnValue.build ?? {};\n returnValue.build.rollupOptions = returnValue.build.rollupOptions ?? {};\n returnValue.build.rollupOptions.external =\n returnValue.build.rollupOptions.external ?? [];\n\n if (typeof returnValue.build.rollupOptions.external === \"function\") {\n // in case the developer has defined a custom external function\n // we wrap it and check our excluded modules first and call the original function if needed\n const originalExternal = returnValue.build.rollupOptions.external;\n\n returnValue.build.rollupOptions.external = (id, ...args) => {\n if (excludedModules.some(m => typeof m === id)) {\n return true;\n }\n\n return originalExternal(id, ...args);\n };\n } else {\n // otherwise we just add our excluded modules to the list supplied by the developer\n const externalModules: (string | RegExp)[] = [];\n\n if (Array.isArray(returnValue.build.rollupOptions.external)) {\n externalModules.push(...returnValue.build.rollupOptions.external);\n } else {\n externalModules.push(returnValue.build.rollupOptions.external);\n }\n\n externalModules.push(...excludedModules);\n\n returnValue.build.rollupOptions.external = externalModules;\n }\n },\n\n // while in dev, we need to prevent 'vite:import-analysis' on runtime modules\n // and also to say they're resolved (as external)\n // (it will still output an error in the console, but it won't break)\n // known issue: https://github.com/vitejs/vite/issues/11633\n configResolved(resolvedConfig) {\n if (!devMode) {\n return;\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore an hack: we want to add the plugin only after the config is resolved\n resolvedConfig.plugins.push(replaceIdPrefix(devKeys));\n },\n\n /**\n * Rollup hook with the info for bundle generation\n * It will be used to create a new configuration with:\n * - bundles replace with the final location (e.g. -> \"bundle\": \"src/pages/Main\" transformed to \"bundle\": \"pages/Main.js\",\n * @param options build options\n * @param bundle bundles information\n */\n async generateBundle(options: NormalizedOutputOptions) {\n if (!externalImportMap) {\n return;\n }\n\n // obtain the directory (dist) where the new config file will be placed\n let targetDir: string | undefined;\n if (options.dir) {\n targetDir = options.dir;\n } else if (options.file) {\n targetDir = path.dirname(options.file);\n }\n\n if (!targetDir) {\n throw new Error(\n \"Please set outputPath, so we can know where to place the json file\"\n );\n }\n\n // create the targetDir if it does not exist\n if (!fs.existsSync(targetDir)) {\n fs.mkdirSync(targetDir, { recursive: true });\n }\n\n // support for external import maps isn't yet available (https://github.com/WICG/import-maps/issues/235)\n // workaround: https://github.com/WICG/import-maps/issues/235#issuecomment-1002340944\n fs.writeFileSync(\n path.resolve(targetDir, \"importmap.js\"),\n importmapScript\n );\n },\n\n // inject the importmap script and also the es-module-shims script\n transformIndexHtml: {\n enforce: \"post\",\n transform: html => ({\n html,\n tags: [\n {\n tag: \"script\",\n attrs: { async: true, src: \"./bundles/es-module-shims.js\" },\n injectTo: \"head-prepend\"\n },\n externalImportMap\n ? {\n tag: \"script\",\n attrs: { src: \"./importmap.js\" },\n injectTo: \"head-prepend\"\n }\n : {\n tag: \"script\",\n attrs: { type: \"importmap\" },\n injectTo: \"head-prepend\",\n children: importmapString\n }\n ]\n })\n }\n },\n externalImportMap\n ? virtual({\n \"/importmap.js\": importmapScript\n })\n : false\n ];\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PluginOption } from "vite";
|
|
2
|
+
interface AppShellVitePluginOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Project root directory. Most likely location of the vite config file.
|
|
5
|
+
*
|
|
6
|
+
* @default process.cwd()
|
|
7
|
+
*/
|
|
8
|
+
root?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Execution mode.
|
|
11
|
+
*/
|
|
12
|
+
mode?: string;
|
|
13
|
+
/**
|
|
14
|
+
* If true, the plugin will generate the importmap with an external js file instead of inline in the html.
|
|
15
|
+
* The map will be saved at the root of the application destination dir and named as "importmap.js"
|
|
16
|
+
*
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
externalImportMap?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Vite plugin to support App Shell apps setup
|
|
23
|
+
* @param opts Plugin options
|
|
24
|
+
*/
|
|
25
|
+
export declare function appShellVitePlugin(opts?: AppShellVitePluginOptions): PluginOption;
|
|
26
|
+
export default appShellVitePlugin;
|
|
27
|
+
//# sourceMappingURL=vite-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAc,MAAM,MAAM,CAAC;AA8QhD,UAAU,yBAAyB;IACjC;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,GAAE,yBAA8B,GACnC,YAAY,CAyJd;AAED,eAAe,kBAAkB,CAAC"}
|