@teambit/preview 1.0.246 → 1.0.248

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.
@@ -10,6 +10,20 @@
10
10
  http://jedwatson.github.io/classnames
11
11
  */
12
12
 
13
+ /*!
14
+ * The buffer module from node.js, for the browser.
15
+ *
16
+ * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
17
+ * @license MIT
18
+ */
19
+
20
+ /*!
21
+ * The buffer module from node.js, for the browser.
22
+ *
23
+ * @author Feross Aboukhadijeh <https://feross.org>
24
+ * @license MIT
25
+ */
26
+
13
27
  /*!
14
28
  * is-primitive <https://github.com/jonschlinkert/is-primitive>
15
29
  *
@@ -32,6 +46,12 @@ See the Apache Version 2.0 License for specific language governing permissions
32
46
  and limitations under the License.
33
47
  ***************************************************************************** */
34
48
 
49
+ /*! https://mths.be/punycode v1.4.1 by @mathias */
50
+
51
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
52
+
53
+ /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
54
+
35
55
  /**
36
56
  * @license
37
57
  * Lodash <https://lodash.com/>
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.preview_preview@1.0.246/dist/preview.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.preview_preview@1.0.246/dist/preview.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.preview_preview@1.0.248/dist/preview.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.preview_preview@1.0.248/dist/preview.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
@@ -31,9 +31,9 @@ function _componentId() {
31
31
  };
32
32
  return data;
33
33
  }
34
- function _crossFetch() {
35
- const data = _interopRequireDefault(require("cross-fetch"));
36
- _crossFetch = function () {
34
+ function _nodeFetch() {
35
+ const data = _interopRequireDefault(require("@pnpm/node-fetch"));
36
+ _nodeFetch = function () {
37
37
  return data;
38
38
  };
39
39
  return data;
@@ -111,7 +111,11 @@ function _sizeEvent() {
111
111
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
112
112
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
113
113
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
114
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // forward linkModules() for generate-link.ts
114
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
115
+ const crossFetch = _nodeFetch().default;
116
+
117
+ // forward linkModules() for generate-link.ts
118
+
115
119
  class PreviewPreview {
116
120
  constructor(
117
121
  /**
@@ -301,7 +305,7 @@ class PreviewPreview {
301
305
  const previewAssetsRoute = `~aspect/preview-assets`;
302
306
  const stringId = id.toString();
303
307
  const url = `/api/${stringId}/${previewAssetsRoute}`;
304
- const res = await (0, _crossFetch().default)(url);
308
+ const res = await crossFetch(url);
305
309
  if (res.status >= 400) {
306
310
  throw new (_exceptions().PreviewNotFound)(previewName);
307
311
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_pubsub","data","require","_harmony","_componentId","_crossFetch","_interopRequireDefault","_memoizee","_lodash","_exceptions","_preview","_events","_renderingContext","_fetchComponentAspects","_previewModules","_htmlUtils","_sizeEvent","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","r","e","Symbol","toPrimitive","call","TypeError","String","Number","PreviewPreview","constructor","pubsub","previewSlot","renderingContextSlot","isReady","Promise","resolve","_setupPromise","PREVIEW_MODULES","onSet","add","rootExt","window","document","body","style","width","previewName","componentId","envId","getLocation","name","getDefault","isDev","preview","getPreview","PreviewNotFound","includesAll","all","include","map","inclPreviewName","includedPreview","undefined","inclPreviewModule","getPreviewModule","selectPreviewModel","fullName","query","getQuery","onlyOverview","getParam","includes","filter","module","isObject","keysWithoutDefault","keys","defaultKeys","intersection","length","componentAspects","getComponentAspects","toString","previewModule","render","getRenderingContext","reportSize","setViewport","setFullScreen","memoize","fetchComponentAspects","max","maxAge","registerClickPubSub","addEventListener","timestamp","Date","now","clickEvent","assign","pub","PreviewAspect","id","ClickInsideAnIframeEvent","has","includedReady","every","included","fullScreen","root","getElementById","height","viewPort","maxWidth","parent","sendPubsubEvent","SizeEvent","offsetWidth","offsetHeight","debounce","counter","interval","setInterval","clearInterval","compShortId","relevantModel","get","Error","componentMap","componentPreviews","fetchComponentPreview","loadComponentPreviews","component","metadata","modulesMap","componentMapMetadata","previewFile","allFiles","fetchComponentPreviewFiles","file","endsWith","addComponentFileElement","loadPreviewScript","previewBundleFileName","addComponentFileScriptElement","addComponentFileLinkElement","catch","err","previewAssetsRoute","stringId","url","res","crossFetch","status","parsed","json","isBundledWithEnv","files","previewRoute","src","loadScript","href","loadLink","globalId","toStringWithoutVersion","componentPreview","registerPreview","register","aspectsFilter","RenderingContext","registerRenderContext","renderContext","previews","values","defaultOne","find","previewCandidate","param","params","URLSearchParams","withoutHash","location","hash","substring","after","split","before","ComponentID","tryFromString","provider","config","exports","PreviewRuntime","PubsubAspect","Slot","withType","addRuntime"],"sources":["preview.preview.runtime.tsx"],"sourcesContent":["import { PubsubAspect, PubsubPreview } from '@teambit/pubsub';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport { ComponentID } from '@teambit/component-id';\nimport crossFetch from 'cross-fetch';\nimport memoize from 'memoizee';\nimport { debounce, intersection, isObject } from 'lodash';\n\nimport { PreviewNotFound } from './exceptions';\nimport { PreviewType } from './preview-type';\nimport { PreviewAspect, PreviewRuntime } from './preview.aspect';\nimport { ClickInsideAnIframeEvent } from './events';\nimport { ModuleFile, PreviewModule } from './types/preview-module';\nimport { RenderingContext } from './rendering-context';\nimport { fetchComponentAspects } from './gql/fetch-component-aspects';\nimport { PREVIEW_MODULES } from './preview-modules';\nimport { loadScript, loadLink } from './html-utils';\nimport { SizeEvent } from './size-event';\n\n// forward linkModules() for generate-link.ts\nexport { linkModules } from './preview-modules';\n\nexport type PreviewSlot = SlotRegistry<PreviewType>;\n\nexport type RenderingContextOptions = { aspectsFilter?: string[] };\nexport type RenderingContextProvider = (options: RenderingContextOptions) => { [key: string]: any };\nexport type RenderingContextSlot = SlotRegistry<RenderingContextProvider>;\n\nexport class PreviewPreview {\n constructor(\n /**\n * register to pubsub\n */\n private pubsub: PubsubPreview,\n\n /**\n * preview slot.\n */\n private previewSlot: PreviewSlot,\n\n private renderingContextSlot: RenderingContextSlot\n ) {\n this.registerClickPubSub();\n }\n\n private registerClickPubSub() {\n window.addEventListener('click', (e) => {\n const timestamp = Date.now();\n const clickEvent = Object.assign({}, e);\n this.pubsub.pub(PreviewAspect.id, new ClickInsideAnIframeEvent(timestamp, clickEvent));\n });\n }\n\n private isDev = false;\n\n private isReady() {\n const { previewName } = this.getLocation();\n const name = previewName || this.getDefault();\n\n if (!PREVIEW_MODULES.has(name)) return false;\n const preview = this.getPreview(name);\n if (!preview) return false;\n const includedReady = preview.include?.every((included) => PREVIEW_MODULES.has(included)) ?? true;\n if (!includedReady) return false;\n\n return true;\n }\n\n private _setupPromise?: Promise<void>;\n setup = () => {\n if (this.isReady()) return Promise.resolve();\n\n this._setupPromise ??= new Promise((resolve) => {\n PREVIEW_MODULES.onSet.add(() => {\n if (this.isReady()) resolve();\n });\n });\n\n return this._setupPromise;\n };\n\n /**\n * render the preview.\n */\n render = async (rootExt?: string) => {\n // fit content always.\n window.document.body.style.width = 'fit-content';\n\n const { previewName, componentId, envId } = this.getLocation();\n const name = previewName || this.getDefault();\n if (rootExt) this.isDev = rootExt === 'teambit.workspace/workspace';\n\n const preview = this.getPreview(name);\n if (!preview || !componentId) {\n throw new PreviewNotFound(previewName);\n }\n\n const includesAll = await Promise.all(\n (preview.include || []).map(async (inclPreviewName) => {\n const includedPreview = this.getPreview(inclPreviewName);\n if (!includedPreview) return undefined;\n\n const inclPreviewModule = await this.getPreviewModule(inclPreviewName, componentId);\n return includedPreview.selectPreviewModel?.(componentId.fullName, inclPreviewModule);\n })\n );\n\n const query = this.getQuery();\n const onlyOverview = this.getParam(query, 'onlyOverview');\n\n const includes =\n onlyOverview === 'true'\n ? []\n : includesAll\n .filter((module) => !!module)\n .map((module) => {\n if (!module.default || !isObject(module.default)) return module;\n // This aims to handle use cases where we have package.json with type:\"module\" in the root\n // in that case sometime we might get the props both under default and in the object root\n const keysWithoutDefault = Object.keys(module).filter((key) => key !== 'default');\n const defaultKeys = Object.keys(module.default);\n if (intersection(keysWithoutDefault, defaultKeys).length === defaultKeys.length) return module.default;\n return module;\n });\n\n // during build / tag, the component is isolated, so all aspects are relevant, and do not require filtering\n const componentAspects = this.isDev ? await this.getComponentAspects(componentId.toString()) : undefined;\n const previewModule = await this.getPreviewModule(name, componentId);\n const render = preview.render(\n componentId,\n envId || '',\n previewModule,\n includes,\n this.getRenderingContext(componentAspects)\n );\n\n this.reportSize();\n this.setViewport();\n this.setFullScreen();\n return render;\n };\n\n setFullScreen() {\n const query = this.getQuery();\n const fullScreen = this.getParam(query, 'fullscreen');\n\n if (!fullScreen) return;\n\n const root = window.document.getElementById('root');\n\n if (root) {\n root.style.height = '100vh';\n }\n }\n\n setViewport() {\n const query = this.getQuery();\n const viewPort = this.getParam(query, 'viewport');\n if (!viewPort) {\n window.document.body.style.width = '100%';\n return;\n }\n\n window.document.body.style.maxWidth = `${viewPort}px`;\n }\n\n reportSize() {\n if (!window?.parent || !window?.document) return;\n // TODO: discuss with gilad for a better way to resolve page loaded here.\n\n const sendPubsubEvent = () => {\n this.pubsub.pub(\n PreviewAspect.id,\n new SizeEvent({\n width: window.document.body.offsetWidth,\n height: window.document.body.offsetHeight,\n })\n );\n };\n\n window.document.body.addEventListener('resize', debounce(sendPubsubEvent, 300));\n\n let counter = 0;\n const interval = setInterval(() => {\n // TODO: think\n counter += 1;\n if (counter > 10) {\n clearInterval(interval);\n return;\n }\n this.pubsub.pub(\n PreviewAspect.id,\n new SizeEvent({\n width: window.document.body.offsetWidth,\n height: window.document.body.offsetHeight,\n })\n );\n }, 200);\n }\n\n async getPreviewModule(previewName: string, id: ComponentID): Promise<PreviewModule> {\n const compShortId = id.fullName;\n\n const relevantModel = PREVIEW_MODULES.get(previewName);\n if (!relevantModel) throw new Error(`[preview.preview] missing preview \"${previewName}\"`);\n if (relevantModel.componentMap[compShortId]) return relevantModel;\n\n const componentPreviews = await this.fetchComponentPreview(id, previewName);\n PREVIEW_MODULES.loadComponentPreviews(compShortId, componentPreviews);\n\n const component = componentPreviews[previewName];\n const metadata = componentPreviews[`${previewName}_metadata`];\n\n return {\n modulesMap: relevantModel.modulesMap,\n componentMap: {\n [id.fullName]: component,\n },\n componentMapMetadata: {\n [id.fullName]: metadata,\n },\n };\n }\n\n async fetchComponentPreview(id: ComponentID, name: string): Promise<Record<string, ModuleFile[]>> {\n let previewFile: string | undefined;\n const allFiles = await this.fetchComponentPreviewFiles(id, name);\n // It's a component bundled with the env\n if (allFiles === null) return {};\n\n await Promise.all(\n allFiles.map((file) => {\n // We want to run the preview file always last\n if (file.endsWith('-preview.js')) {\n previewFile = file;\n return undefined;\n }\n\n return this.addComponentFileElement(id, file);\n })\n );\n\n if (!previewFile) return {};\n return this.loadPreviewScript(id, name, previewFile);\n }\n\n private addComponentFileElement(id: ComponentID, previewBundleFileName: string) {\n if (previewBundleFileName.endsWith('.js')) {\n return this.addComponentFileScriptElement(id, previewBundleFileName);\n }\n\n // TODO - should we load assets other than .css / .js?\n // if (previewBundleFileName.endsWith('.css')) {\n this.addComponentFileLinkElement(id, previewBundleFileName).catch((err) => {\n throw new Error(\n `[preview.preview] failed loading asset \"${previewBundleFileName}\". Error - \"${err?.toString()}\"`\n );\n });\n\n // do NOT await non js assets, as they might never load (like images), and not critical for rendering.\n return undefined;\n }\n\n private async fetchComponentPreviewFiles(id: ComponentID, previewName: string): Promise<string[] | null> {\n const previewAssetsRoute = `~aspect/preview-assets`;\n const stringId = id.toString();\n const url = `/api/${stringId}/${previewAssetsRoute}`;\n\n const res = await crossFetch(url);\n if (res.status >= 400) {\n throw new PreviewNotFound(previewName);\n }\n const parsed = await res.json();\n // This is component bundled with the env, no reason to bring the files, as they will be the files of the env\n if (parsed.isBundledWithEnv) {\n return null;\n }\n if (!parsed.files || !parsed.files.length) {\n throw new PreviewNotFound(previewName);\n }\n return parsed.files;\n }\n\n private addComponentFileScriptElement(id: ComponentID, previewBundleFileName: string) {\n const previewRoute = `~aspect/component-preview`;\n const stringId = id.toString();\n const src = `/api/${stringId}/${previewRoute}/${previewBundleFileName}`;\n return loadScript({ src });\n }\n\n private addComponentFileLinkElement(id: ComponentID, previewBundleFileName: string) {\n const stringId = id.toString();\n const previewRoute = `~aspect/component-preview`;\n const href = `/api/${stringId}/${previewRoute}/${previewBundleFileName}`;\n return loadLink({ href });\n }\n\n private async loadPreviewScript(id: ComponentID, previewName: string, previewBundleFileName: string) {\n const previewRoute = `~aspect/component-preview`;\n const src = `/api/${id.toString()}/${previewRoute}/${previewBundleFileName}`;\n await loadScript({ src });\n\n // TODO - replace with jsonp\n const globalId = `${id.toStringWithoutVersion()}-preview`;\n const componentPreview = window[globalId];\n if (!componentPreview) throw new PreviewNotFound(previewName);\n\n return componentPreview as Record<string, ModuleFile[]>;\n }\n\n private getComponentAspects = memoize(fetchComponentAspects, {\n max: 100,\n maxAge: 12 * 60 * 60 * 1000,\n });\n\n /**\n * register a new preview.\n */\n registerPreview(preview: PreviewType) {\n this.previewSlot.register(preview);\n return this;\n }\n\n /**\n * get the preview rendering context.\n */\n getRenderingContext(aspectsFilter?: string[]) {\n return new RenderingContext(this.renderingContextSlot, { aspectsFilter });\n }\n\n /**\n * allows aspects to add rendering contexts.\n * render context is available through all preview definitions.\n */\n registerRenderContext(renderContext: RenderingContextProvider) {\n this.renderingContextSlot.register(renderContext);\n return this;\n }\n\n getDefault() {\n const previews = this.previewSlot.values();\n const defaultOne = previews.find((previewCandidate) => previewCandidate.default);\n\n return defaultOne?.name || previews[0].name;\n }\n\n private getPreview(previewName: string): undefined | PreviewType {\n const previews = this.previewSlot.values();\n const preview = previews.find((previewCandidate) => previewCandidate.name === previewName);\n\n return preview;\n }\n\n getParam(query: string, param: string) {\n const params = new URLSearchParams(query);\n return params.get(param);\n }\n\n getQuery() {\n const withoutHash = window.location.hash.substring(1);\n const [, after] = withoutHash.split('?');\n return after;\n }\n\n private getLocation() {\n const withoutHash = window.location.hash.substring(1);\n const [before, after] = withoutHash.split('?');\n\n return {\n previewName: this.getParam(after, 'preview'),\n envId: this.getParam(after, 'env'),\n componentId: ComponentID.tryFromString(before),\n };\n }\n\n static runtime = PreviewRuntime;\n\n static dependencies = [PubsubAspect];\n\n static slots = [Slot.withType<PreviewType>(), Slot.withType<RenderingContextProvider>()];\n\n static async provider(\n [pubsub]: [PubsubPreview],\n config,\n [previewSlot, renderingContextSlot]: [PreviewSlot, RenderingContextSlot]\n ) {\n const preview = new PreviewPreview(pubsub, previewSlot, renderingContextSlot);\n\n window.addEventListener('hashchange', () => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n preview.render();\n });\n\n return preview;\n }\n}\n\nPreviewA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","_componentId","_nodeFetch","_interopRequireDefault","_memoizee","_lodash","_exceptions","_preview","_events","_renderingContext","_fetchComponentAspects","_previewModules","_htmlUtils","_sizeEvent","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","r","e","Symbol","toPrimitive","call","TypeError","String","Number","crossFetch","_crossFetch","PreviewPreview","constructor","pubsub","previewSlot","renderingContextSlot","isReady","Promise","resolve","_setupPromise","PREVIEW_MODULES","onSet","add","rootExt","window","document","body","style","width","previewName","componentId","envId","getLocation","name","getDefault","isDev","preview","getPreview","PreviewNotFound","includesAll","all","include","map","inclPreviewName","includedPreview","undefined","inclPreviewModule","getPreviewModule","selectPreviewModel","fullName","query","getQuery","onlyOverview","getParam","includes","filter","module","isObject","keysWithoutDefault","keys","defaultKeys","intersection","length","componentAspects","getComponentAspects","toString","previewModule","render","getRenderingContext","reportSize","setViewport","setFullScreen","memoize","fetchComponentAspects","max","maxAge","registerClickPubSub","addEventListener","timestamp","Date","now","clickEvent","assign","pub","PreviewAspect","id","ClickInsideAnIframeEvent","has","includedReady","every","included","fullScreen","root","getElementById","height","viewPort","maxWidth","parent","sendPubsubEvent","SizeEvent","offsetWidth","offsetHeight","debounce","counter","interval","setInterval","clearInterval","compShortId","relevantModel","get","Error","componentMap","componentPreviews","fetchComponentPreview","loadComponentPreviews","component","metadata","modulesMap","componentMapMetadata","previewFile","allFiles","fetchComponentPreviewFiles","file","endsWith","addComponentFileElement","loadPreviewScript","previewBundleFileName","addComponentFileScriptElement","addComponentFileLinkElement","catch","err","previewAssetsRoute","stringId","url","res","status","parsed","json","isBundledWithEnv","files","previewRoute","src","loadScript","href","loadLink","globalId","toStringWithoutVersion","componentPreview","registerPreview","register","aspectsFilter","RenderingContext","registerRenderContext","renderContext","previews","values","defaultOne","find","previewCandidate","param","params","URLSearchParams","withoutHash","location","hash","substring","after","split","before","ComponentID","tryFromString","provider","config","exports","PreviewRuntime","PubsubAspect","Slot","withType","addRuntime"],"sources":["preview.preview.runtime.tsx"],"sourcesContent":["import { PubsubAspect, PubsubPreview } from '@teambit/pubsub';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport { ComponentID } from '@teambit/component-id';\nimport _crossFetch from '@pnpm/node-fetch';\nimport memoize from 'memoizee';\nimport { debounce, intersection, isObject } from 'lodash';\n\nimport { PreviewNotFound } from './exceptions';\nimport { PreviewType } from './preview-type';\nimport { PreviewAspect, PreviewRuntime } from './preview.aspect';\nimport { ClickInsideAnIframeEvent } from './events';\nimport { ModuleFile, PreviewModule } from './types/preview-module';\nimport { RenderingContext } from './rendering-context';\nimport { fetchComponentAspects } from './gql/fetch-component-aspects';\nimport { PREVIEW_MODULES } from './preview-modules';\nimport { loadScript, loadLink } from './html-utils';\nimport { SizeEvent } from './size-event';\n\nconst crossFetch: typeof fetch = _crossFetch as unknown as typeof fetch;\n\n// forward linkModules() for generate-link.ts\nexport { linkModules } from './preview-modules';\n\nexport type PreviewSlot = SlotRegistry<PreviewType>;\n\nexport type RenderingContextOptions = { aspectsFilter?: string[] };\nexport type RenderingContextProvider = (options: RenderingContextOptions) => { [key: string]: any };\nexport type RenderingContextSlot = SlotRegistry<RenderingContextProvider>;\n\nexport class PreviewPreview {\n constructor(\n /**\n * register to pubsub\n */\n private pubsub: PubsubPreview,\n\n /**\n * preview slot.\n */\n private previewSlot: PreviewSlot,\n\n private renderingContextSlot: RenderingContextSlot\n ) {\n this.registerClickPubSub();\n }\n\n private registerClickPubSub() {\n window.addEventListener('click', (e) => {\n const timestamp = Date.now();\n const clickEvent = Object.assign({}, e);\n this.pubsub.pub(PreviewAspect.id, new ClickInsideAnIframeEvent(timestamp, clickEvent));\n });\n }\n\n private isDev = false;\n\n private isReady() {\n const { previewName } = this.getLocation();\n const name = previewName || this.getDefault();\n\n if (!PREVIEW_MODULES.has(name)) return false;\n const preview = this.getPreview(name);\n if (!preview) return false;\n const includedReady = preview.include?.every((included) => PREVIEW_MODULES.has(included)) ?? true;\n if (!includedReady) return false;\n\n return true;\n }\n\n private _setupPromise?: Promise<void>;\n setup = () => {\n if (this.isReady()) return Promise.resolve();\n\n this._setupPromise ??= new Promise((resolve) => {\n PREVIEW_MODULES.onSet.add(() => {\n if (this.isReady()) resolve();\n });\n });\n\n return this._setupPromise;\n };\n\n /**\n * render the preview.\n */\n render = async (rootExt?: string) => {\n // fit content always.\n window.document.body.style.width = 'fit-content';\n\n const { previewName, componentId, envId } = this.getLocation();\n const name = previewName || this.getDefault();\n if (rootExt) this.isDev = rootExt === 'teambit.workspace/workspace';\n\n const preview = this.getPreview(name);\n if (!preview || !componentId) {\n throw new PreviewNotFound(previewName);\n }\n\n const includesAll = await Promise.all(\n (preview.include || []).map(async (inclPreviewName) => {\n const includedPreview = this.getPreview(inclPreviewName);\n if (!includedPreview) return undefined;\n\n const inclPreviewModule = await this.getPreviewModule(inclPreviewName, componentId);\n return includedPreview.selectPreviewModel?.(componentId.fullName, inclPreviewModule);\n })\n );\n\n const query = this.getQuery();\n const onlyOverview = this.getParam(query, 'onlyOverview');\n\n const includes =\n onlyOverview === 'true'\n ? []\n : includesAll\n .filter((module) => !!module)\n .map((module) => {\n if (!module.default || !isObject(module.default)) return module;\n // This aims to handle use cases where we have package.json with type:\"module\" in the root\n // in that case sometime we might get the props both under default and in the object root\n const keysWithoutDefault = Object.keys(module).filter((key) => key !== 'default');\n const defaultKeys = Object.keys(module.default);\n if (intersection(keysWithoutDefault, defaultKeys).length === defaultKeys.length) return module.default;\n return module;\n });\n\n // during build / tag, the component is isolated, so all aspects are relevant, and do not require filtering\n const componentAspects = this.isDev ? await this.getComponentAspects(componentId.toString()) : undefined;\n const previewModule = await this.getPreviewModule(name, componentId);\n const render = preview.render(\n componentId,\n envId || '',\n previewModule,\n includes,\n this.getRenderingContext(componentAspects)\n );\n\n this.reportSize();\n this.setViewport();\n this.setFullScreen();\n return render;\n };\n\n setFullScreen() {\n const query = this.getQuery();\n const fullScreen = this.getParam(query, 'fullscreen');\n\n if (!fullScreen) return;\n\n const root = window.document.getElementById('root');\n\n if (root) {\n root.style.height = '100vh';\n }\n }\n\n setViewport() {\n const query = this.getQuery();\n const viewPort = this.getParam(query, 'viewport');\n if (!viewPort) {\n window.document.body.style.width = '100%';\n return;\n }\n\n window.document.body.style.maxWidth = `${viewPort}px`;\n }\n\n reportSize() {\n if (!window?.parent || !window?.document) return;\n // TODO: discuss with gilad for a better way to resolve page loaded here.\n\n const sendPubsubEvent = () => {\n this.pubsub.pub(\n PreviewAspect.id,\n new SizeEvent({\n width: window.document.body.offsetWidth,\n height: window.document.body.offsetHeight,\n })\n );\n };\n\n window.document.body.addEventListener('resize', debounce(sendPubsubEvent, 300));\n\n let counter = 0;\n const interval = setInterval(() => {\n // TODO: think\n counter += 1;\n if (counter > 10) {\n clearInterval(interval);\n return;\n }\n this.pubsub.pub(\n PreviewAspect.id,\n new SizeEvent({\n width: window.document.body.offsetWidth,\n height: window.document.body.offsetHeight,\n })\n );\n }, 200);\n }\n\n async getPreviewModule(previewName: string, id: ComponentID): Promise<PreviewModule> {\n const compShortId = id.fullName;\n\n const relevantModel = PREVIEW_MODULES.get(previewName);\n if (!relevantModel) throw new Error(`[preview.preview] missing preview \"${previewName}\"`);\n if (relevantModel.componentMap[compShortId]) return relevantModel;\n\n const componentPreviews = await this.fetchComponentPreview(id, previewName);\n PREVIEW_MODULES.loadComponentPreviews(compShortId, componentPreviews);\n\n const component = componentPreviews[previewName];\n const metadata = componentPreviews[`${previewName}_metadata`];\n\n return {\n modulesMap: relevantModel.modulesMap,\n componentMap: {\n [id.fullName]: component,\n },\n componentMapMetadata: {\n [id.fullName]: metadata,\n },\n };\n }\n\n async fetchComponentPreview(id: ComponentID, name: string): Promise<Record<string, ModuleFile[]>> {\n let previewFile: string | undefined;\n const allFiles = await this.fetchComponentPreviewFiles(id, name);\n // It's a component bundled with the env\n if (allFiles === null) return {};\n\n await Promise.all(\n allFiles.map((file) => {\n // We want to run the preview file always last\n if (file.endsWith('-preview.js')) {\n previewFile = file;\n return undefined;\n }\n\n return this.addComponentFileElement(id, file);\n })\n );\n\n if (!previewFile) return {};\n return this.loadPreviewScript(id, name, previewFile);\n }\n\n private addComponentFileElement(id: ComponentID, previewBundleFileName: string) {\n if (previewBundleFileName.endsWith('.js')) {\n return this.addComponentFileScriptElement(id, previewBundleFileName);\n }\n\n // TODO - should we load assets other than .css / .js?\n // if (previewBundleFileName.endsWith('.css')) {\n this.addComponentFileLinkElement(id, previewBundleFileName).catch((err) => {\n throw new Error(\n `[preview.preview] failed loading asset \"${previewBundleFileName}\". Error - \"${err?.toString()}\"`\n );\n });\n\n // do NOT await non js assets, as they might never load (like images), and not critical for rendering.\n return undefined;\n }\n\n private async fetchComponentPreviewFiles(id: ComponentID, previewName: string): Promise<string[] | null> {\n const previewAssetsRoute = `~aspect/preview-assets`;\n const stringId = id.toString();\n const url = `/api/${stringId}/${previewAssetsRoute}`;\n\n const res = await crossFetch(url);\n if (res.status >= 400) {\n throw new PreviewNotFound(previewName);\n }\n const parsed = await res.json();\n // This is component bundled with the env, no reason to bring the files, as they will be the files of the env\n if (parsed.isBundledWithEnv) {\n return null;\n }\n if (!parsed.files || !parsed.files.length) {\n throw new PreviewNotFound(previewName);\n }\n return parsed.files;\n }\n\n private addComponentFileScriptElement(id: ComponentID, previewBundleFileName: string) {\n const previewRoute = `~aspect/component-preview`;\n const stringId = id.toString();\n const src = `/api/${stringId}/${previewRoute}/${previewBundleFileName}`;\n return loadScript({ src });\n }\n\n private addComponentFileLinkElement(id: ComponentID, previewBundleFileName: string) {\n const stringId = id.toString();\n const previewRoute = `~aspect/component-preview`;\n const href = `/api/${stringId}/${previewRoute}/${previewBundleFileName}`;\n return loadLink({ href });\n }\n\n private async loadPreviewScript(id: ComponentID, previewName: string, previewBundleFileName: string) {\n const previewRoute = `~aspect/component-preview`;\n const src = `/api/${id.toString()}/${previewRoute}/${previewBundleFileName}`;\n await loadScript({ src });\n\n // TODO - replace with jsonp\n const globalId = `${id.toStringWithoutVersion()}-preview`;\n const componentPreview = window[globalId];\n if (!componentPreview) throw new PreviewNotFound(previewName);\n\n return componentPreview as Record<string, ModuleFile[]>;\n }\n\n private getComponentAspects = memoize(fetchComponentAspects, {\n max: 100,\n maxAge: 12 * 60 * 60 * 1000,\n });\n\n /**\n * register a new preview.\n */\n registerPreview(preview: PreviewType) {\n this.previewSlot.register(preview);\n return this;\n }\n\n /**\n * get the preview rendering context.\n */\n getRenderingContext(aspectsFilter?: string[]) {\n return new RenderingContext(this.renderingContextSlot, { aspectsFilter });\n }\n\n /**\n * allows aspects to add rendering contexts.\n * render context is available through all preview definitions.\n */\n registerRenderContext(renderContext: RenderingContextProvider) {\n this.renderingContextSlot.register(renderContext);\n return this;\n }\n\n getDefault() {\n const previews = this.previewSlot.values();\n const defaultOne = previews.find((previewCandidate) => previewCandidate.default);\n\n return defaultOne?.name || previews[0].name;\n }\n\n private getPreview(previewName: string): undefined | PreviewType {\n const previews = this.previewSlot.values();\n const preview = previews.find((previewCandidate) => previewCandidate.name === previewName);\n\n return preview;\n }\n\n getParam(query: string, param: string) {\n const params = new URLSearchParams(query);\n return params.get(param);\n }\n\n getQuery() {\n const withoutHash = window.location.hash.substring(1);\n const [, after] = withoutHash.split('?');\n return after;\n }\n\n private getLocation() {\n const withoutHash = window.location.hash.substring(1);\n const [before, after] = withoutHash.split('?');\n\n return {\n previewName: this.getParam(after, 'preview'),\n envId: this.getParam(after, 'env'),\n componentId: ComponentID.tryFromString(before),\n };\n }\n\n static runtime = PreviewRuntime;\n\n static dependencies = [PubsubAspect];\n\n static slots = [Slot.withType<PreviewType>(), Slot.withType<RenderingContextProvider>()];\n\n static async provider(\n [pubsub]: [PubsubPreview],\n config,\n [previewSlot, renderingContextSlot]: [PreviewSlot, RenderingContextSlot]\n ) {\n const preview = new PreviewPreview(pubsub, previewSlot, renderingContextSlot);\n\n window.addEventListener('hashchange', () => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n preview.render();\n });\n\n return preview;\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Ac,CAAC","ignoreList":[]}
@@ -73,6 +73,10 @@ function createPreBundleConfig(outputDir, entryFile) {
73
73
  dns: false,
74
74
  fs: false,
75
75
  stream: false,
76
+ http: _webpack2().fallbacks.http,
77
+ https: _webpack2().fallbacks.https,
78
+ zlib: _webpack2().fallbacks.zlib,
79
+ crypto: _webpack2().fallbacks.crypto,
76
80
  http2: false,
77
81
  net: false,
78
82
  tls: false,
@@ -1 +1 @@
1
- {"version":3,"names":["_reactWebpack","data","require","_webpack","_webpackMerge","_webpack2","_webpackManifestPlugin","createWebpackConfig","outputDir","entryFile","baseConfig","configBaseFactory","preBundleConfig","createPreBundleConfig","combined","merge","mode","process","env","BIT_DEBUG_PREVIEW_BUNDLE","stats","children","errorDetails","entry","main","resolve","alias","react","fallback","module","path","fallbacks","dgram","dns","fs","stream","http2","net","tls","child_process","output","publicPath","chunkFilename","filename","library","type","externalsType","externals","plugins","WebpackManifestPlugin","fileName","generate","seed","files","entrypoints","manifestFiles","reduce","manifest","file","name","entrypointFiles","filter","endsWith","ProvidePlugin","fallbacksProvidePluginConfig"],"sources":["webpack.config.ts"],"sourcesContent":["import { configBaseFactory } from '@teambit/react.webpack.react-webpack';\n\nimport { Configuration, ProvidePlugin } from 'webpack';\nimport { merge } from 'webpack-merge';\nimport { fallbacksProvidePluginConfig, fallbacks } from '@teambit/webpack';\nimport { WebpackManifestPlugin } from 'webpack-manifest-plugin';\n\nexport function createWebpackConfig(outputDir: string, entryFile: string): Configuration {\n const baseConfig = configBaseFactory(true);\n const preBundleConfig = createPreBundleConfig(outputDir, entryFile);\n\n // @ts-ignore that's an issue because of different types/webpack version\n const combined = merge(baseConfig, preBundleConfig);\n\n // @ts-ignore that's an issue because of different types/webpack version\n return combined;\n}\n\nfunction createPreBundleConfig(outputDir: string, entryFile: string) {\n const mode = process.env.BIT_DEBUG_PREVIEW_BUNDLE ? 'development' : 'production';\n const preBundleConfig: Configuration = {\n stats: {\n children: true,\n errorDetails: true,\n },\n mode,\n entry: {\n main: entryFile,\n },\n resolve: {\n alias: {\n 'react/jsx-runtime': require.resolve('react/jsx-runtime'),\n react: require.resolve('react'),\n 'react-dom': require.resolve('react-dom'),\n },\n fallback: {\n module: false,\n path: fallbacks.path,\n dgram: false,\n dns: false,\n fs: false,\n stream: false,\n http2: false,\n net: false,\n tls: false,\n child_process: false,\n process: fallbacks.process,\n },\n },\n output: {\n path: outputDir,\n publicPath: '/',\n chunkFilename: 'static/js/[name].[contenthash:8].chunk.cjs',\n filename: 'static/js/[name].[contenthash:8].cjs',\n library: {\n type: 'commonjs-static',\n },\n },\n externalsType: 'commonjs',\n externals: ['react', 'react-dom', '@mdx-js/react', '@teambit/mdx.ui.mdx-scope-context'],\n plugins: [\n // Generate an asset manifest file with the following content:\n // - \"files\" key: Mapping of all asset filenames to their corresponding\n // output file so that tools can pick it up without having to parse\n // `index.html`\n // can be used to reconstruct the HTML if necessary\n new WebpackManifestPlugin({\n fileName: 'asset-manifest.json',\n generate: (seed, files, entrypoints) => {\n const manifestFiles = files.reduce((manifest, file) => {\n manifest[file.name] = file.path;\n return manifest;\n }, seed);\n const entrypointFiles = entrypoints.main.filter((fileName) => !fileName.endsWith('.map'));\n\n // @ts-ignore - https://github.com/shellscape/webpack-manifest-plugin/issues/276\n return {\n files: manifestFiles,\n entrypoints: entrypointFiles,\n } as Record<string, string>;\n },\n }),\n\n new ProvidePlugin({ process: fallbacksProvidePluginConfig.process }),\n ],\n };\n\n return preBundleConfig;\n}\n"],"mappings":";;;;;;AAAA,SAAAA,cAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,aAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,SAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,QAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,cAAA;EAAA,MAAAH,IAAA,GAAAC,OA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AAC;EAED,OAAOL,eAAe;AACxB","ignoreList":[]}
1
+ {"version":3,"names":["_reactWebpack","data","require","_webpack","_webpackMerge","_webpack2","_webpackManifestPlugin","createWebpackConfig","outputDir","entryFile","baseConfig","configBaseFactory","preBundleConfig","createPreBundleConfig","combined","merge","mode","process","env","BIT_DEBUG_PREVIEW_BUNDLE","stats","children","errorDetails","entry","main","resolve","alias","react","fallback","module","path","fallbacks","dgram","dns","fs","stream","http","https","zlib","crypto","http2","net","tls","child_process","output","publicPath","chunkFilename","filename","library","type","externalsType","externals","plugins","WebpackManifestPlugin","fileName","generate","seed","files","entrypoints","manifestFiles","reduce","manifest","file","name","entrypointFiles","filter","endsWith","ProvidePlugin","fallbacksProvidePluginConfig"],"sources":["webpack.config.ts"],"sourcesContent":["import { configBaseFactory } from '@teambit/react.webpack.react-webpack';\n\nimport { Configuration, ProvidePlugin } from 'webpack';\nimport { merge } from 'webpack-merge';\nimport { fallbacksProvidePluginConfig, fallbacks } from '@teambit/webpack';\nimport { WebpackManifestPlugin } from 'webpack-manifest-plugin';\n\nexport function createWebpackConfig(outputDir: string, entryFile: string): Configuration {\n const baseConfig = configBaseFactory(true);\n const preBundleConfig = createPreBundleConfig(outputDir, entryFile);\n\n // @ts-ignore that's an issue because of different types/webpack version\n const combined = merge(baseConfig, preBundleConfig);\n\n // @ts-ignore that's an issue because of different types/webpack version\n return combined;\n}\n\nfunction createPreBundleConfig(outputDir: string, entryFile: string) {\n const mode = process.env.BIT_DEBUG_PREVIEW_BUNDLE ? 'development' : 'production';\n const preBundleConfig: Configuration = {\n stats: {\n children: true,\n errorDetails: true,\n },\n mode,\n entry: {\n main: entryFile,\n },\n resolve: {\n alias: {\n 'react/jsx-runtime': require.resolve('react/jsx-runtime'),\n react: require.resolve('react'),\n 'react-dom': require.resolve('react-dom'),\n },\n fallback: {\n module: false,\n path: fallbacks.path,\n dgram: false,\n dns: false,\n fs: false,\n stream: false,\n http: fallbacks.http,\n https: fallbacks.https,\n zlib: fallbacks.zlib,\n crypto: fallbacks.crypto,\n http2: false,\n net: false,\n tls: false,\n child_process: false,\n process: fallbacks.process,\n },\n },\n output: {\n path: outputDir,\n publicPath: '/',\n chunkFilename: 'static/js/[name].[contenthash:8].chunk.cjs',\n filename: 'static/js/[name].[contenthash:8].cjs',\n library: {\n type: 'commonjs-static',\n },\n },\n externalsType: 'commonjs',\n externals: ['react', 'react-dom', '@mdx-js/react', '@teambit/mdx.ui.mdx-scope-context'],\n plugins: [\n // Generate an asset manifest file with the following content:\n // - \"files\" key: Mapping of all asset filenames to their corresponding\n // output file so that tools can pick it up without having to parse\n // `index.html`\n // can be used to reconstruct the HTML if necessary\n new WebpackManifestPlugin({\n fileName: 'asset-manifest.json',\n generate: (seed, files, entrypoints) => {\n const manifestFiles = files.reduce((manifest, file) => {\n manifest[file.name] = file.path;\n return manifest;\n }, seed);\n const entrypointFiles = entrypoints.main.filter((fileName) => !fileName.endsWith('.map'));\n\n // @ts-ignore - https://github.com/shellscape/webpack-manifest-plugin/issues/276\n return {\n files: manifestFiles,\n entrypoints: entrypointFiles,\n } as Record<string, string>;\n },\n }),\n\n new ProvidePlugin({ process: fallbacksProvidePluginConfig.process }),\n ],\n };\n\n return preBundleConfig;\n}\n"],"mappings":";;;;;;AAAA,SAAAA,cAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,aAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,SAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,QAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,cAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,aAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,UAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,SAAA,YA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AExE,CAAC;EAED,OAAOL,eAAe;AACxB","ignoreList":[]}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/preview",
3
- "version": "1.0.246",
3
+ "version": "1.0.248",
4
4
  "homepage": "https://bit.cloud/teambit/preview/preview",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.preview",
8
8
  "name": "preview",
9
- "version": "1.0.246"
9
+ "version": "1.0.248"
10
10
  },
11
11
  "dependencies": {
12
12
  "mime": "2.5.2",
@@ -30,28 +30,28 @@
30
30
  "@teambit/express": "0.0.961",
31
31
  "@teambit/logger": "0.0.955",
32
32
  "@teambit/ui-foundation.ui.pages.static-error": "0.0.99",
33
- "@teambit/builder": "1.0.246",
34
- "@teambit/bundler": "1.0.246",
35
- "@teambit/component": "1.0.246",
33
+ "@teambit/builder": "1.0.248",
34
+ "@teambit/bundler": "1.0.248",
35
+ "@teambit/component": "1.0.248",
36
36
  "@teambit/preview.ui.component-preview": "1.0.12",
37
- "@teambit/aspect-loader": "1.0.246",
37
+ "@teambit/aspect-loader": "1.0.248",
38
38
  "@teambit/cli": "0.0.862",
39
- "@teambit/dependency-resolver": "1.0.246",
40
- "@teambit/envs": "1.0.246",
39
+ "@teambit/dependency-resolver": "1.0.248",
40
+ "@teambit/envs": "1.0.248",
41
41
  "@teambit/toolbox.path.to-windows-compatible-path": "0.0.496",
42
- "@teambit/ui": "1.0.246",
43
- "@teambit/isolator": "1.0.246",
42
+ "@teambit/ui": "1.0.248",
43
+ "@teambit/isolator": "1.0.248",
44
44
  "@teambit/harmony.modules.harmony-root-generator": "0.0.4",
45
45
  "@teambit/cache": "0.0.955",
46
- "@teambit/graphql": "1.0.246",
47
- "@teambit/pkg": "1.0.246",
48
- "@teambit/pubsub": "1.0.246",
49
- "@teambit/scope": "1.0.246",
50
- "@teambit/watcher": "1.0.246",
51
- "@teambit/workspace": "1.0.246",
52
- "@teambit/compiler": "1.0.246",
46
+ "@teambit/graphql": "1.0.248",
47
+ "@teambit/pkg": "1.0.248",
48
+ "@teambit/pubsub": "1.0.248",
49
+ "@teambit/scope": "1.0.248",
50
+ "@teambit/watcher": "1.0.248",
51
+ "@teambit/workspace": "1.0.248",
52
+ "@teambit/compiler": "1.0.248",
53
53
  "@teambit/preview.cli.webpack-events-listener": "0.0.175",
54
- "@teambit/webpack": "1.0.246"
54
+ "@teambit/webpack": "1.0.248"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@types/mime": "2.0.3",
@@ -60,7 +60,7 @@
60
60
  "@types/webpack": "5.28.1",
61
61
  "@types/object-hash": "1.3.4",
62
62
  "@types/memoizee": "0.4.5",
63
- "cross-fetch": "3.1.5",
63
+ "@pnpm/node-fetch": "^1.0.0",
64
64
  "memoizee": "0.4.15",
65
65
  "@types/chai": "4.2.15",
66
66
  "chai": "4.3.0",
@@ -1,7 +1,7 @@
1
1
  import { PubsubAspect, PubsubPreview } from '@teambit/pubsub';
2
2
  import { Slot, SlotRegistry } from '@teambit/harmony';
3
3
  import { ComponentID } from '@teambit/component-id';
4
- import crossFetch from 'cross-fetch';
4
+ import _crossFetch from '@pnpm/node-fetch';
5
5
  import memoize from 'memoizee';
6
6
  import { debounce, intersection, isObject } from 'lodash';
7
7
 
@@ -16,6 +16,8 @@ import { PREVIEW_MODULES } from './preview-modules';
16
16
  import { loadScript, loadLink } from './html-utils';
17
17
  import { SizeEvent } from './size-event';
18
18
 
19
+ const crossFetch: typeof fetch = _crossFetch as unknown as typeof fetch;
20
+
19
21
  // forward linkModules() for generate-link.ts
20
22
  export { linkModules } from './preview-modules';
21
23
 
@@ -40,6 +40,10 @@ function createPreBundleConfig(outputDir: string, entryFile: string) {
40
40
  dns: false,
41
41
  fs: false,
42
42
  stream: false,
43
+ http: fallbacks.http,
44
+ https: fallbacks.https,
45
+ zlib: fallbacks.zlib,
46
+ crypto: fallbacks.crypto,
43
47
  http2: false,
44
48
  net: false,
45
49
  tls: false,