@teambit/preview 0.0.777 → 0.0.778

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.
Files changed (33) hide show
  1. package/bundler/chunks.ts +2 -7
  2. package/bundler/create-peer-link.spec.ts +33 -0
  3. package/bundler/create-peers-link.ts +48 -0
  4. package/dist/bundler/chunks.d.ts +1 -1
  5. package/dist/bundler/chunks.js +1 -6
  6. package/dist/bundler/chunks.js.map +1 -1
  7. package/dist/bundler/create-peer-link.spec.d.ts +1 -0
  8. package/dist/bundler/create-peer-link.spec.js +42 -0
  9. package/dist/bundler/create-peer-link.spec.js.map +1 -0
  10. package/dist/bundler/create-peers-link.d.ts +2 -0
  11. package/dist/bundler/create-peers-link.js +100 -0
  12. package/dist/bundler/create-peers-link.js.map +1 -0
  13. package/dist/env-preview-template.task.js +13 -3
  14. package/dist/env-preview-template.task.js.map +1 -1
  15. package/dist/generate-link.js +11 -7
  16. package/dist/generate-link.js.map +1 -1
  17. package/dist/html-utils.d.ts +6 -0
  18. package/dist/html-utils.js +43 -0
  19. package/dist/html-utils.js.map +1 -0
  20. package/dist/preview.preview.runtime.js +27 -31
  21. package/dist/preview.preview.runtime.js.map +1 -1
  22. package/dist/strategies/component-strategy.js +13 -10
  23. package/dist/strategies/component-strategy.js.map +1 -1
  24. package/dist/strategies/generate-component-link.js +3 -3
  25. package/dist/strategies/generate-component-link.js.map +1 -1
  26. package/html-utils.tsx +29 -0
  27. package/package-tar/teambit-preview-0.0.778.tgz +0 -0
  28. package/package.json +16 -15
  29. package/{preview-1656732493790.js → preview-1656905226178.js} +3 -3
  30. package/preview.preview.runtime.tsx +19 -32
  31. package/strategies/component-strategy.ts +16 -16
  32. package/strategies/generate-component-link.ts +3 -3
  33. package/package-tar/teambit-preview-0.0.777.tgz +0 -0
@@ -119,12 +119,16 @@ export class ComponentBundlingStrategy implements BundlingStrategy {
119
119
  component: Component,
120
120
  context: ComputeTargetsContext
121
121
  ): Promise<ComponentEntry> {
122
- const path = await this.computePaths(previewDefs, context, component);
122
+ const componentPreviewPath = await this.computePaths(previewDefs, context, component);
123
123
  const [componentPath] = this.getPaths(context, component, [component.mainFile]);
124
- const componentPreviewChunkId = this.getComponentChunkId(component.id, 'preview');
124
+
125
+ const chunks = {
126
+ componentPreview: this.getComponentChunkId(component.id, 'preview'),
127
+ component: context.splitComponentBundle ? component.id.toStringWithoutVersion() : undefined,
128
+ };
125
129
 
126
130
  const entries = {
127
- [componentPreviewChunkId]: {
131
+ [chunks.componentPreview]: {
128
132
  filename: this.getComponentChunkFileName(
129
133
  component.id.toString({
130
134
  fsCompatible: true,
@@ -132,17 +136,14 @@ export class ComponentBundlingStrategy implements BundlingStrategy {
132
136
  }),
133
137
  'preview'
134
138
  ),
135
- import: path,
136
- // dependOn: component.id.toStringWithoutVersion(),
137
- library: {
138
- name: componentPreviewChunkId,
139
- type: 'umd',
140
- },
139
+ import: componentPreviewPath,
140
+ dependOn: chunks.component,
141
+ library: { name: chunks.componentPreview, type: 'umd' },
141
142
  },
142
143
  };
143
- if (context.splitComponentBundle) {
144
- const componentChunkId = component.id.toStringWithoutVersion();
145
- entries[componentChunkId] = {
144
+
145
+ if (chunks.component) {
146
+ entries[chunks.component] = {
146
147
  filename: this.getComponentChunkFileName(
147
148
  component.id.toString({
148
149
  fsCompatible: true,
@@ -150,13 +151,12 @@ export class ComponentBundlingStrategy implements BundlingStrategy {
150
151
  }),
151
152
  'component'
152
153
  ),
154
+ dependOn: undefined,
153
155
  import: componentPath,
154
- library: {
155
- name: componentChunkId,
156
- type: 'umd',
157
- },
156
+ library: { name: chunks.component, type: 'umd' },
158
157
  };
159
158
  }
159
+
160
160
  return { component, entries };
161
161
  }
162
162
 
@@ -17,15 +17,15 @@ export function generateComponentLink(modules: ModuleVar[]): string {
17
17
  // import per preview file
18
18
  const importStr: string = links
19
19
  .map(({ entries }) => entries.map(({ path, linkName }) => `import * as ${linkName} from '${path}'`).join(';\n'))
20
- .join('\n');
20
+ .join(';\n');
21
21
 
22
22
  // export files group per preview
23
23
  const exportsString: string = links
24
24
  .map(({ name, entries }) => `export const ${name} = [${entries.map((entry) => entry.linkName).join(', ')}]`)
25
25
  .join(';\n');
26
26
 
27
- return `${importStr}
27
+ return `${importStr};
28
28
 
29
- ${exportsString}
29
+ ${exportsString};
30
30
  `;
31
31
  }