Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: wc-3 tweaks to pass type-checking and cleanup task definitions #31348

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion apps/vr-tests-web-components/.storybook/main.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ const tsPaths = new TsconfigPathsPlugin({
configFile: tsConfigPath,
});

module.exports = /** @type {import('../../../.storybook/main').StorybookBaseConfig} */ ({
// TODO - these types are copied from root ./storybook/main.js as if we would like to use those as is, it will force us to add our custom storybook plugins as devDeps to WC
// - refactor this to be shared

/** @typedef {import('@storybook/core-common').StorybookConfig} StorybookBaseConfig */

module.exports = /** @type {StorybookBaseConfig} */ ({
addons: [
{
name: '@storybook/addon-docs',
Expand Down
2 changes: 1 addition & 1 deletion apps/vr-tests-web-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"format": "prettier . -w --ignore-path ../../.prettierignore",
"lint": "eslint src --ext .ts,.tsx",
"start": "start-storybook",
"type-check": "tsc",
"type-check": "tsc --baseUrl . --noEmit",
chrisdholt marked this conversation as resolved.
Show resolved Hide resolved
"vr:build": "yarn build",
"vr:test": "storywright --browsers chromium --url dist/storybook --destpath dist/screenshots --waitTimeScreenshot 500 --concurrency 4 --headless true"
},
Expand Down
3 changes: 1 addition & 2 deletions apps/vr-tests-web-components/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"experimentalDecorators": true,
"resolveJsonModule": true,
"allowJs": true,
"jsx": "react",
"moduleResolution": "Node16"
chrisdholt marked this conversation as resolved.
Show resolved Hide resolved
"jsx": "react"
},
"include": ["./src", "./.storybook/*"]
}
19 changes: 18 additions & 1 deletion packages/web-components/.storybook/main.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,24 @@ const tsPaths = new TsconfigPathsPlugin({
configFile: tsConfigPath,
});

module.exports = /** @type {Omit<import('../../../.storybook/main').StorybookConfig,'typescript'|'babel'|'previewHead'>} */ ({
// TODO - these types are copied from root ./storybook/main.js as if we would like to use those as is, it will force us to add our custom storybook plugins as devDeps to WC
// - refactor this to be shared

/**
* @typedef {import('@storybook/core-common').StorybookConfig} StorybookBaseConfig
*
* @typedef {{
* babel: (options: Record<string, unknown>) => Promise<Record<string, unknown>>;
* previewHead: (head: string) => string;
* }} StorybookExtraConfig
*
* @typedef {StorybookBaseConfig &
* Required<Pick<StorybookBaseConfig, 'stories' | 'addons' | 'webpackFinal'>> &
* StorybookExtraConfig
* } StorybookConfig
*/

module.exports = /** @type {Omit<StorybookConfig,'typescript'|'babel'|'previewHead'>} */ ({
stories: ['../src/**/*.stories.@(ts|mdx)'],
staticDirs: ['../public'],
core: {
Expand Down
6 changes: 2 additions & 4 deletions packages/web-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@
"./dist/esm/toggle-button/define.js"
],
"scripts": {
"tsc": "tsc",
Hotell marked this conversation as resolved.
Show resolved Hide resolved
"api-extractor": "api-extractor",
"type-check": "echo 'TODO'",
"benchmark": "yarn clean && yarn compile:benchmark && yarn compile && node ./scripts/run-benchmarks",
"compile": "node ./scripts/compile",
"compile:benchmark": "rollup -c rollup.bench.js",
Expand All @@ -199,8 +198,7 @@
"devDependencies": {
"@types/web": "^0.0.142",
"@storybook/html": "6.5.15",
"@tensile-perf/web-components": "~0.1.13",
"rimraf": "^3.0.2"
Hotell marked this conversation as resolved.
Show resolved Hide resolved
"@tensile-perf/web-components": "~0.1.13"
},
"dependencies": {
"@microsoft/fast-element": "2.0.0-beta.26",
Expand Down
44 changes: 31 additions & 13 deletions packages/web-components/scripts/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,47 @@
* Usage: node build/clean.js %path%
*/
import * as path from 'path';
import rimraf from 'rimraf';
import * as fsPromises from 'node:fs/promises';
import yargs from 'yargs';

const argv = yargs.argv;

/**
* All paths passed to the clean script
*/
const paths = argv._;
main();

/**
* Function to remove a given path
*/
function cleanPath(cleanPath) {
const removePath = path.resolve(process.cwd(), cleanPath);
rimraf(removePath, () => {

const result = fsPromises.rm(removePath, { recursive: true }).then(() => {
console.log(removePath, 'cleaned');
});

return result;
}

/**
* Clean all paths
*/
if (Array.isArray(paths)) {
paths.forEach(cleanPath);
function main() {
const argv = yargs.argv;

/**
* All paths passed to the clean script
*/
const paths = argv._;

/**
* Clean all paths
*/
if (!Array.isArray(paths)) {
throw new Error('"paths" must be an array');
}

const result = paths.map(cleanPath);

Promise.all(result)
.then(() => {
console.log('All paths cleaned');
})
.catch(error => {
console.error(error);
process.exit(1);
});
}
Loading