@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.
- package/bundler/chunks.ts +2 -7
- package/bundler/create-peer-link.spec.ts +33 -0
- package/bundler/create-peers-link.ts +48 -0
- package/dist/bundler/chunks.d.ts +1 -1
- package/dist/bundler/chunks.js +1 -6
- package/dist/bundler/chunks.js.map +1 -1
- package/dist/bundler/create-peer-link.spec.d.ts +1 -0
- package/dist/bundler/create-peer-link.spec.js +42 -0
- package/dist/bundler/create-peer-link.spec.js.map +1 -0
- package/dist/bundler/create-peers-link.d.ts +2 -0
- package/dist/bundler/create-peers-link.js +100 -0
- package/dist/bundler/create-peers-link.js.map +1 -0
- package/dist/env-preview-template.task.js +13 -3
- package/dist/env-preview-template.task.js.map +1 -1
- package/dist/generate-link.js +11 -7
- package/dist/generate-link.js.map +1 -1
- package/dist/html-utils.d.ts +6 -0
- package/dist/html-utils.js +43 -0
- package/dist/html-utils.js.map +1 -0
- package/dist/preview.preview.runtime.js +27 -31
- package/dist/preview.preview.runtime.js.map +1 -1
- package/dist/strategies/component-strategy.js +13 -10
- package/dist/strategies/component-strategy.js.map +1 -1
- package/dist/strategies/generate-component-link.js +3 -3
- package/dist/strategies/generate-component-link.js.map +1 -1
- package/html-utils.tsx +29 -0
- package/package-tar/teambit-preview-0.0.778.tgz +0 -0
- package/package.json +16 -15
- package/{preview-1656732493790.js → preview-1656905226178.js} +3 -3
- package/preview.preview.runtime.tsx +19 -32
- package/strategies/component-strategy.ts +16 -16
- package/strategies/generate-component-link.ts +3 -3
- 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
|
|
122
|
+
const componentPreviewPath = await this.computePaths(previewDefs, context, component);
|
|
123
123
|
const [componentPath] = this.getPaths(context, component, [component.mainFile]);
|
|
124
|
-
|
|
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
|
-
[
|
|
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:
|
|
136
|
-
|
|
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
|
-
|
|
144
|
-
|
|
145
|
-
entries[
|
|
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('
|
|
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
|
}
|
|
Binary file
|