Skip to content

Commit a2c2853

Browse files
chore(barebones): improve infrastructure and testing setup (#5811)
1 parent c7a695e commit a2c2853

File tree

10 files changed

+103
-116
lines changed

10 files changed

+103
-116
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ parameters:
2222
# 3. Commit this change to the PR branch where the changes exist.
2323
current_golden_images_hash:
2424
type: string
25-
default: 71be19cab16d3ff600820e801341f14629ad06d9
25+
default: 3fab915a1480ba61e7654c12937d831685826902
2626
wireit_cache_name:
2727
type: string
2828
default: wireit

first-gen/projects/documentation/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@
258258
]
259259
},
260260
"serve": {
261-
"command": "vite --config vite.config.js",
261+
"command": "web-dev-server --config web-dev-server.config.js",
262262
"dependencies": [
263263
{
264264
"script": "build:assets"

first-gen/projects/documentation/vite.config.js

Lines changed: 0 additions & 38 deletions
This file was deleted.

first-gen/projects/documentation/web-dev-server.config.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,21 @@ import rollupJson from '@rollup/plugin-json';
1717
const alias = fromRollup(rollupAlias);
1818
const json = fromRollup(rollupJson);
1919

20+
// Custom plugin to replace process.env.NODE_ENV in all files
21+
const replaceProcessEnv = () => ({
22+
name: 'replace-process-env',
23+
transform(context) {
24+
if (context.response.is('js')) {
25+
return {
26+
body: context.body.replace(
27+
/process\.env\.NODE_ENV/g,
28+
'"development"'
29+
),
30+
};
31+
}
32+
},
33+
});
34+
2035
export default {
2136
open: false,
2237
watch: true,
@@ -31,6 +46,7 @@ export default {
3146
rootDir: '_site',
3247
plugins: [
3348
json(),
49+
replaceProcessEnv(),
3450
alias({
3551
entries: [
3652
{

first-gen/tools/base/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
"css"
120120
],
121121
"dependencies": {
122+
"@swc/core": "workspace:*",
122123
"lit": "^2.5.0 || ^3.1.3"
123124
},
124125
"types": "./src/index.d.ts",

first-gen/tools/base/src/sizedMixin.ts

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -9,76 +9,4 @@
99
* OF ANY KIND, either express or implied. See the License for the specific language
1010
* governing permissions and limitations under the License.
1111
*/
12-
import { PropertyValues, ReactiveElement } from 'lit';
13-
import { property } from 'lit/decorators.js';
14-
15-
type Constructor<T = Record<string, unknown>> = {
16-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
17-
new (...args: any[]): T;
18-
prototype: T;
19-
};
20-
21-
export type ElementSize = 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl';
22-
export const ElementSizes: Record<string, ElementSize> = {
23-
xxs: 'xxs',
24-
xs: 'xs',
25-
s: 's',
26-
m: 'm',
27-
l: 'l',
28-
xl: 'xl',
29-
xxl: 'xxl',
30-
};
31-
export type DefaultElementSize = Exclude<ElementSize, 'xxs' | 'xs' | 'xxl'>;
32-
33-
export interface SizedElementInterface {
34-
size: ElementSize;
35-
}
36-
37-
export function SizedMixin<T extends Constructor<ReactiveElement>>(
38-
constructor: T,
39-
{
40-
validSizes = ['s', 'm', 'l', 'xl'],
41-
noDefaultSize,
42-
defaultSize = 'm',
43-
}: {
44-
validSizes?: ElementSize[];
45-
noDefaultSize?: boolean;
46-
defaultSize?: ElementSize;
47-
} = {}
48-
): T & Constructor<SizedElementInterface> {
49-
class SizedElement extends constructor {
50-
@property({ type: String })
51-
public get size(): ElementSize {
52-
return this._size || defaultSize;
53-
}
54-
55-
public set size(value: ElementSize) {
56-
const fallbackSize = noDefaultSize ? null : defaultSize;
57-
const size = (
58-
value ? value.toLocaleLowerCase() : value
59-
) as ElementSize;
60-
const validSize = (
61-
validSizes.includes(size) ? size : fallbackSize
62-
) as ElementSize;
63-
if (validSize) {
64-
this.setAttribute('size', validSize);
65-
}
66-
if (this._size === validSize) {
67-
return;
68-
}
69-
const oldSize = this._size;
70-
this._size = validSize;
71-
this.requestUpdate('size', oldSize);
72-
}
73-
74-
private _size: ElementSize | null = defaultSize;
75-
76-
protected override update(changes: PropertyValues): void {
77-
if (!this.hasAttribute('size') && !noDefaultSize) {
78-
this.setAttribute('size', this.size);
79-
}
80-
super.update(changes);
81-
}
82-
}
83-
return SizedElement;
84-
}
12+
export * from '@swc/core/shared/base/sizedMixin.js';
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
diff --git a/node_modules/@web/test-runner-coverage-v8/dist/index.js b/node_modules/@web/test-runner-coverage-v8/dist/index.js
2+
index 997bcfc..b19cf60 100644
3+
--- a/node_modules/@web/test-runner-coverage-v8/dist/index.js
4+
+++ b/node_modules/@web/test-runner-coverage-v8/dist/index.js
5+
@@ -63,7 +63,16 @@ async function v8ToIstanbul(config, testFiles, coverage, userAgent) {
6+
!path.startsWith('/__web-test-runner') &&
7+
!path.startsWith('/__web-dev-server')) {
8+
try {
9+
- const filePath = (0, path_1.join)(config.rootDir, (0, utils_1.toFilePath)(path));
10+
+ // Handle __wds-outside-root__ paths which reference files outside the rootDir
11+
+ let filePath;
12+
+ const outsideRootMatch = path.match(/^\/__wds-outside-root__\/\d+\/(.+)$/);
13+
+ if (outsideRootMatch) {
14+
+ // For outside-root files, resolve relative to workspace root (parent of rootDir)
15+
+ const workspaceRoot = (0, path_1.dirname)(config.rootDir);
16+
+ filePath = (0, path_1.join)(workspaceRoot, (0, utils_1.toFilePath)(outsideRootMatch[1]));
17+
+ } else {
18+
+ filePath = (0, path_1.join)(config.rootDir, (0, utils_1.toFilePath)(path));
19+
+ }
20+
if (!testFiles.includes(filePath) && included(filePath) && !excluded(filePath)) {
21+
const browserUrl = `${url.pathname}${url.search}${url.hash}`;
22+
const cachedSource = cachedSources.get(browserUrl);

second-gen/packages/core/package.json

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,61 @@
2929
"types": "./dist/shared/base/index.d.ts",
3030
"import": "./dist/shared/base/index.js"
3131
},
32-
"./shared/*": {
33-
"types": "./dist/shared/*.d.ts",
34-
"import": "./dist/shared/*.js"
32+
"./shared/base/Base": {
33+
"types": "./dist/shared/base/Base.d.ts",
34+
"import": "./dist/shared/base/Base.js"
35+
},
36+
"./shared/base/Base.js": {
37+
"types": "./dist/shared/base/Base.d.ts",
38+
"import": "./dist/shared/base/Base.js"
39+
},
40+
"./shared/base/sizedMixin": {
41+
"types": "./dist/shared/base/sizedMixin.d.ts",
42+
"import": "./dist/shared/base/sizedMixin.js"
43+
},
44+
"./shared/base/sizedMixin.js": {
45+
"types": "./dist/shared/base/sizedMixin.d.ts",
46+
"import": "./dist/shared/base/sizedMixin.js"
47+
},
48+
"./shared/base/define-element": {
49+
"types": "./dist/shared/base/define-element.d.ts",
50+
"import": "./dist/shared/base/define-element.js"
51+
},
52+
"./shared/base/define-element.js": {
53+
"types": "./dist/shared/base/define-element.d.ts",
54+
"import": "./dist/shared/base/define-element.js"
55+
},
56+
"./shared/base/version": {
57+
"types": "./dist/shared/base/version.d.ts",
58+
"import": "./dist/shared/base/version.js"
59+
},
60+
"./shared/base/version.js": {
61+
"types": "./dist/shared/base/version.d.ts",
62+
"import": "./dist/shared/base/version.js"
63+
},
64+
"./shared/get-label-from-slot": {
65+
"types": "./dist/shared/get-label-from-slot.d.ts",
66+
"import": "./dist/shared/get-label-from-slot.js"
67+
},
68+
"./shared/get-label-from-slot.js": {
69+
"types": "./dist/shared/get-label-from-slot.d.ts",
70+
"import": "./dist/shared/get-label-from-slot.js"
71+
},
72+
"./shared/observe-slot-presence": {
73+
"types": "./dist/shared/observe-slot-presence.d.ts",
74+
"import": "./dist/shared/observe-slot-presence.js"
75+
},
76+
"./shared/observe-slot-presence.js": {
77+
"types": "./dist/shared/observe-slot-presence.d.ts",
78+
"import": "./dist/shared/observe-slot-presence.js"
79+
},
80+
"./shared/observe-slot-text": {
81+
"types": "./dist/shared/observe-slot-text.d.ts",
82+
"import": "./dist/shared/observe-slot-text.js"
83+
},
84+
"./shared/observe-slot-text.js": {
85+
"types": "./dist/shared/observe-slot-text.d.ts",
86+
"import": "./dist/shared/observe-slot-text.js"
3587
}
3688
},
3789
"files": [

second-gen/packages/swc/.storybook/preview-head.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
<link rel="preconnect" href="https://use.typekit.net" />
2+
<link rel="dns-prefetch" href="https://use.typekit.net" />
3+
<!-- For Adobe Clean font support -->
4+
<link rel="stylesheet" href="https://use.typekit.net/evk7lzt.css" />
5+
16
<style>
27
/* Fix for Storybook's zoom wrapper interfering with forced-colors mode */
38
@media (forced-colors: active) {

yarn.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5426,6 +5426,7 @@ __metadata:
54265426
version: 0.0.0-use.local
54275427
resolution: "@spectrum-web-components/base@workspace:first-gen/tools/base"
54285428
dependencies:
5429+
"@swc/core": "workspace:*"
54295430
lit: "npm:^2.5.0 || ^3.1.3"
54305431
languageName: unknown
54315432
linkType: soft

0 commit comments

Comments
 (0)