@playwright/experimental-ct-core 1.33.0-alpha-apr-18-2023

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 ADDED
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Portions Copyright (c) Microsoft Corporation.
190
+ Portions Copyright 2017 Google Inc.
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ > **BEWARE** This package is EXPERIMENTAL and does not respect semver.
2
+
3
+ Read more at https://playwright.dev/docs/test-components
package/cli.js ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Copyright (c) Microsoft Corporation.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ module.exports = require('@playwright/test/cli');
@@ -0,0 +1,312 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createPlugin = createPlugin;
7
+ var _fs = _interopRequireDefault(require("fs"));
8
+ var _path = _interopRequireDefault(require("path"));
9
+ var _babelBundle = require("@playwright/test/lib/common/babelBundle");
10
+ var _utilsBundle = require("@playwright/test/lib/utilsBundle");
11
+ var _tsxTransform = require("@playwright/test/lib/common/tsxTransform");
12
+ var _utils = require("playwright-core/lib/utils");
13
+ var _compilationCache = require("@playwright/test/lib/common/compilationCache");
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ /**
16
+ * Copyright (c) Microsoft Corporation.
17
+ *
18
+ * Licensed under the Apache License, Version 2.0 (the "License");
19
+ * you may not use this file except in compliance with the License.
20
+ * You may obtain a copy of the License at
21
+ *
22
+ * http://www.apache.org/licenses/LICENSE-2.0
23
+ *
24
+ * Unless required by applicable law or agreed to in writing, software
25
+ * distributed under the License is distributed on an "AS IS" BASIS,
26
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27
+ * See the License for the specific language governing permissions and
28
+ * limitations under the License.
29
+ */
30
+
31
+ let stoppableServer;
32
+ const playwrightVersion = (0, _utils.getPlaywrightVersion)();
33
+ const importReactRE = /(^|\n|;)import\s+(\*\s+as\s+)?React(,|\s+)/;
34
+ const compiledReactRE = /(const|var)\s+React\s*=/;
35
+ function createPlugin(registerSourceFile, frameworkPluginFactory) {
36
+ let configDir;
37
+ let config;
38
+ return {
39
+ name: 'playwright-vite-plugin',
40
+ setup: async (configObject, configDirectory) => {
41
+ config = configObject;
42
+ configDir = configDirectory;
43
+ },
44
+ begin: async suite => {
45
+ var _viteConfig$build;
46
+ const use = config.projects[0].use;
47
+ const port = use.ctPort || 3100;
48
+ const viteConfig = typeof use.ctViteConfig === 'function' ? await use.ctViteConfig() : use.ctViteConfig || {};
49
+ const relativeTemplateDir = use.ctTemplateDir || 'playwright';
50
+ const rootDir = viteConfig.root || configDir;
51
+ const templateDir = _path.default.join(rootDir, relativeTemplateDir);
52
+ const outDir = (viteConfig === null || viteConfig === void 0 ? void 0 : (_viteConfig$build = viteConfig.build) === null || _viteConfig$build === void 0 ? void 0 : _viteConfig$build.outDir) || (use.ctCacheDir ? _path.default.resolve(rootDir, use.ctCacheDir) : _path.default.resolve(templateDir, '.cache'));
53
+ const buildInfoFile = _path.default.join(outDir, 'metainfo.json');
54
+ let buildExists = false;
55
+ let buildInfo;
56
+ const registerSource = await _fs.default.promises.readFile(registerSourceFile, 'utf-8');
57
+ const registerSourceHash = (0, _utils.calculateSha1)(registerSource);
58
+ const {
59
+ version: viteVersion
60
+ } = require('vite/package.json');
61
+ try {
62
+ buildInfo = JSON.parse(await _fs.default.promises.readFile(buildInfoFile, 'utf-8'));
63
+ (0, _utils.assert)(buildInfo.version === playwrightVersion);
64
+ (0, _utils.assert)(buildInfo.viteVersion === viteVersion);
65
+ (0, _utils.assert)(buildInfo.registerSourceHash === registerSourceHash);
66
+ buildExists = true;
67
+ } catch (e) {
68
+ buildInfo = {
69
+ version: playwrightVersion,
70
+ viteVersion,
71
+ registerSourceHash,
72
+ components: [],
73
+ tests: {},
74
+ sources: {}
75
+ };
76
+ }
77
+ const componentRegistry = new Map();
78
+ // 1. Re-parse changed tests and collect required components.
79
+ const hasNewTests = await checkNewTests(suite, buildInfo, componentRegistry);
80
+ // 2. Check if the set of required components has changed.
81
+ const hasNewComponents = await checkNewComponents(buildInfo, componentRegistry);
82
+ // 3. Check component sources.
83
+ const sourcesDirty = !buildExists || hasNewComponents || (await checkSources(buildInfo));
84
+ // 4. Update component info.
85
+ buildInfo.components = [...componentRegistry.values()];
86
+ viteConfig.root = rootDir;
87
+ viteConfig.preview = {
88
+ port,
89
+ ...viteConfig.preview
90
+ };
91
+
92
+ // React heuristic. If we see a component in a file with .js extension,
93
+ // consider it a potential JSX-in-JS scenario and enable JSX loader for all
94
+ // .js files.
95
+ if (hasJSComponents(buildInfo.components)) {
96
+ viteConfig.esbuild = {
97
+ loader: 'jsx',
98
+ include: /.*\.jsx?$/,
99
+ exclude: []
100
+ };
101
+ viteConfig.optimizeDeps = {
102
+ esbuildOptions: {
103
+ loader: {
104
+ '.js': 'jsx'
105
+ }
106
+ }
107
+ };
108
+ }
109
+ const {
110
+ build,
111
+ preview
112
+ } = require('vite');
113
+ // Build config unconditionally, either build or build & preview will use it.
114
+ viteConfig.plugins = viteConfig.plugins || [await frameworkPluginFactory()];
115
+ // But only add out own plugin when we actually build / transform.
116
+ if (sourcesDirty) viteConfig.plugins.push(vitePlugin(registerSource, relativeTemplateDir, buildInfo, componentRegistry));
117
+ viteConfig.configFile = viteConfig.configFile || false;
118
+ viteConfig.define = viteConfig.define || {};
119
+ viteConfig.define.__VUE_PROD_DEVTOOLS__ = true;
120
+ viteConfig.css = viteConfig.css || {};
121
+ viteConfig.css.devSourcemap = true;
122
+ viteConfig.build = {
123
+ ...viteConfig.build,
124
+ outDir,
125
+ target: 'esnext',
126
+ minify: false,
127
+ rollupOptions: {
128
+ treeshake: false,
129
+ input: {
130
+ index: _path.default.join(templateDir, 'index.html')
131
+ }
132
+ },
133
+ sourcemap: true
134
+ };
135
+ if (sourcesDirty) {
136
+ await build(viteConfig);
137
+ await _fs.default.promises.rename(`${outDir}/${relativeTemplateDir}/index.html`, `${outDir}/index.html`);
138
+ }
139
+ if (hasNewTests || hasNewComponents || sourcesDirty) await _fs.default.promises.writeFile(buildInfoFile, JSON.stringify(buildInfo, undefined, 2));
140
+ for (const [filename, testInfo] of Object.entries(buildInfo.tests)) (0, _compilationCache.setExternalDependencies)(filename, testInfo.deps);
141
+ const previewServer = await preview(viteConfig);
142
+ stoppableServer = (0, _utilsBundle.stoppable)(previewServer.httpServer, 0);
143
+ const isAddressInfo = x => x === null || x === void 0 ? void 0 : x.address;
144
+ const address = previewServer.httpServer.address();
145
+ if (isAddressInfo(address)) {
146
+ const protocol = viteConfig.preview.https ? 'https:' : 'http:';
147
+ process.env.PLAYWRIGHT_TEST_BASE_URL = `${protocol}//localhost:${address.port}`;
148
+ }
149
+ },
150
+ end: async () => {
151
+ await new Promise(f => stoppableServer.stop(f));
152
+ }
153
+ };
154
+ }
155
+ async function checkSources(buildInfo) {
156
+ for (const [source, sourceInfo] of Object.entries(buildInfo.sources)) {
157
+ try {
158
+ const timestamp = (await _fs.default.promises.stat(source)).mtimeMs;
159
+ if (sourceInfo.timestamp !== timestamp) return true;
160
+ } catch (e) {
161
+ return true;
162
+ }
163
+ }
164
+ return false;
165
+ }
166
+ async function checkNewTests(suite, buildInfo, componentRegistry) {
167
+ const testFiles = new Set();
168
+ for (const project of suite.suites) {
169
+ for (const file of project.suites) testFiles.add(file.location.file);
170
+ }
171
+ let hasNewTests = false;
172
+ for (const testFile of testFiles) {
173
+ var _buildInfo$tests$test;
174
+ const timestamp = (await _fs.default.promises.stat(testFile)).mtimeMs;
175
+ if (((_buildInfo$tests$test = buildInfo.tests[testFile]) === null || _buildInfo$tests$test === void 0 ? void 0 : _buildInfo$tests$test.timestamp) !== timestamp) {
176
+ const components = await parseTestFile(testFile);
177
+ for (const component of components) componentRegistry.set(component.fullName, component);
178
+ buildInfo.tests[testFile] = {
179
+ timestamp,
180
+ components: components.map(c => c.fullName),
181
+ deps: []
182
+ };
183
+ hasNewTests = true;
184
+ }
185
+ }
186
+ return hasNewTests;
187
+ }
188
+ async function checkNewComponents(buildInfo, componentRegistry) {
189
+ const newComponents = [...componentRegistry.keys()];
190
+ const oldComponents = new Map(buildInfo.components.map(c => [c.fullName, c]));
191
+ let hasNewComponents = false;
192
+ for (const c of newComponents) {
193
+ if (!oldComponents.has(c)) {
194
+ hasNewComponents = true;
195
+ break;
196
+ }
197
+ }
198
+ for (const c of oldComponents.values()) componentRegistry.set(c.fullName, c);
199
+ return hasNewComponents;
200
+ }
201
+ async function parseTestFile(testFile) {
202
+ const text = await _fs.default.promises.readFile(testFile, 'utf-8');
203
+ const ast = (0, _babelBundle.parse)(text, {
204
+ errorRecovery: true,
205
+ plugins: ['typescript', 'jsx'],
206
+ sourceType: 'module'
207
+ });
208
+ const componentUsages = (0, _tsxTransform.collectComponentUsages)(ast);
209
+ const result = [];
210
+ (0, _babelBundle.traverse)(ast, {
211
+ enter: p => {
212
+ if (_babelBundle.types.isImportDeclaration(p.node)) {
213
+ const importNode = p.node;
214
+ if (!_babelBundle.types.isStringLiteral(importNode.source)) return;
215
+ for (const specifier of importNode.specifiers) {
216
+ if (!componentUsages.names.has(specifier.local.name)) continue;
217
+ if (_babelBundle.types.isImportNamespaceSpecifier(specifier)) continue;
218
+ result.push((0, _tsxTransform.componentInfo)(specifier, importNode.source.value, testFile));
219
+ }
220
+ }
221
+ }
222
+ });
223
+ return result;
224
+ }
225
+ function vitePlugin(registerSource, relativeTemplateDir, buildInfo, componentRegistry) {
226
+ buildInfo.sources = {};
227
+ let moduleResolver;
228
+ return {
229
+ name: 'playwright:component-index',
230
+ configResolved(config) {
231
+ moduleResolver = config.createResolver();
232
+ },
233
+ async transform(content, id) {
234
+ const queryIndex = id.indexOf('?');
235
+ const file = queryIndex !== -1 ? id.substring(0, queryIndex) : id;
236
+ if (!buildInfo.sources[file]) {
237
+ try {
238
+ const timestamp = (await _fs.default.promises.stat(file)).mtimeMs;
239
+ buildInfo.sources[file] = {
240
+ timestamp
241
+ };
242
+ } catch {
243
+ // Silent if can't read the file.
244
+ }
245
+ }
246
+
247
+ // Vite React plugin will do this for .jsx files, but not .js files.
248
+ if (id.endsWith('.js') && content.includes('React.createElement') && !content.match(importReactRE) && !content.match(compiledReactRE)) {
249
+ const code = `import React from 'react';\n${content}`;
250
+ return {
251
+ code,
252
+ map: {
253
+ mappings: ''
254
+ }
255
+ };
256
+ }
257
+ const indexTs = _path.default.join(relativeTemplateDir, 'index.ts');
258
+ const indexTsx = _path.default.join(relativeTemplateDir, 'index.tsx');
259
+ const indexJs = _path.default.join(relativeTemplateDir, 'index.js');
260
+ const indexJsx = _path.default.join(relativeTemplateDir, 'index.jsx');
261
+ const idResolved = _path.default.resolve(id);
262
+ if (!idResolved.endsWith(indexTs) && !idResolved.endsWith(indexTsx) && !idResolved.endsWith(indexJs) && !idResolved.endsWith(indexJsx)) return;
263
+ const folder = _path.default.dirname(id);
264
+ const lines = [content, ''];
265
+ lines.push(registerSource);
266
+ for (const [alias, value] of componentRegistry) {
267
+ const importPath = value.isModuleOrAlias ? value.importPath : './' + _path.default.relative(folder, value.importPath).replace(/\\/g, '/');
268
+ if (value.importedName) lines.push(`import { ${value.importedName} as ${alias} } from '${importPath}';`);else lines.push(`import ${alias} from '${importPath}';`);
269
+ }
270
+ lines.push(`pwRegister({ ${[...componentRegistry.keys()].join(',\n ')} });`);
271
+ return {
272
+ code: lines.join('\n'),
273
+ map: {
274
+ mappings: ''
275
+ }
276
+ };
277
+ },
278
+ async writeBundle() {
279
+ const componentDeps = new Map();
280
+ for (const component of componentRegistry.values()) {
281
+ const id = await moduleResolver(component.importPath);
282
+ if (!id) continue;
283
+ const deps = new Set();
284
+ collectViteModuleDependencies(this, id, deps);
285
+ componentDeps.set(component.fullName, deps);
286
+ }
287
+ for (const testInfo of Object.values(buildInfo.tests)) {
288
+ const deps = new Set();
289
+ for (const fullName of testInfo.components) {
290
+ for (const dep of componentDeps.get(fullName) || []) deps.add(dep);
291
+ }
292
+ testInfo.deps = [...deps];
293
+ }
294
+ }
295
+ };
296
+ }
297
+ function collectViteModuleDependencies(context, id, deps) {
298
+ if (!_path.default.isAbsolute(id)) return;
299
+ const normalizedId = _path.default.normalize(id);
300
+ if (deps.has(normalizedId)) return;
301
+ deps.add(normalizedId);
302
+ const module = context.getModuleInfo(id);
303
+ for (const importedId of (module === null || module === void 0 ? void 0 : module.importedIds) || []) collectViteModuleDependencies(context, importedId, deps);
304
+ for (const importedId of (module === null || module === void 0 ? void 0 : module.dynamicallyImportedIds) || []) collectViteModuleDependencies(context, importedId, deps);
305
+ }
306
+ function hasJSComponents(components) {
307
+ for (const component of components) {
308
+ const extname = _path.default.extname(component.importPath);
309
+ if (extname === '.js' || !extname && _fs.default.existsSync(component.importPath + '.js')) return true;
310
+ }
311
+ return false;
312
+ }
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@playwright/experimental-ct-core",
3
+ "version": "1.33.0-alpha-apr-18-2023",
4
+ "description": "Playwright Component Testing Helpers",
5
+ "repository": "github:Microsoft/playwright",
6
+ "homepage": "https://playwright.dev",
7
+ "engines": {
8
+ "node": ">=14"
9
+ },
10
+ "author": {
11
+ "name": "Microsoft Corporation"
12
+ },
13
+ "license": "Apache-2.0",
14
+ "exports": {
15
+ "./cli": "./cli.js",
16
+ "./lib/vitePlugin": "./lib/vitePlugin.js"
17
+ },
18
+ "dependencies": {
19
+ "vite": "^4.2.1",
20
+ "@playwright/test": "1.33.0-alpha-apr-18-2023"
21
+ },
22
+ "bin": {
23
+ "playwright": "./cli.js"
24
+ }
25
+ }