Skip to content
Open
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
23 changes: 6 additions & 17 deletions commonVite.config.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
import { dirname, resolve as resolvePath } from 'path';
import { fileURLToPath } from 'url';

import { unpluginSemcoreResolve } from '@semcore/builder/plugins';
import copy from 'rollup-plugin-copy';
import { createUnplugin } from 'unplugin';
import type { UserConfig } from 'vite';
import { defineConfig } from 'vite';

import { loadSemcoreSources } from './website/docs/.vitepress/load-semcore-sources';
import { resolveSemcoreSources } from './website/docs/.vitepress/resolve-semcore-sources';
const rootDir = resolvePath(dirname(fileURLToPath(import.meta.url)));

export default defineConfig({
plugins: [
createUnplugin<{}>(() => ({
name: 'semcore-styles-resolver',
async resolveId(id) {
if (!id.endsWith('.shadow.css')) return null;
return await resolveSemcoreSources(id);
},
loadInclude: (id) => {
return id.includes('/semcore/');
},
async load(id) {
return await loadSemcoreSources(id, true);
},
enforce: 'pre',
})).vite({}),
unpluginSemcoreResolve.vite({ rootPath: rootDir }),
],
esbuild: {
legalComments: 'inline',
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"start": "pnpm storybook",
"build": "pnpm run clean && pnpm --filter @semcore/theme run build && pnpm --filter @semcore/core run build && pnpm build:icons && pnpm build:illustration && pnpm --filter @semcore/base-components run build && pnpm --filter @semcore/dropdown run build && pnpm --filter @semcore/* --filter !@semcore/icon --filter !@semcore/core --filter !@semcore/base-components --filter !@semcore/illustration --filter !@semcore/dropdown --filter !@semcore/ui run build",
"process-theme": "pnpm --filter @semcore/theme build",
"typecheck": "pnpm --filter @semcore/* --filter !@semcore/babel-plugin-root --filter !@semcore/babel-plugin-styles --filter !@semcore/babel-plugin-react-semcore --filter !@semcore/babel-preset-ui --filter !@semcore/testing-utils --filter !@semcore/email --filter !@semcore/icon-transform-svg --filter !@semcore/shadow-loader exec tsc --noEmit",
"install-n-test": "pnpm install && pnpm test",
"install-n-browser-test": "pnpm install && pnpm browser-test",
"install-n-axe-test": "pnpm install && pnpm axe-test",
Expand Down
4,112 changes: 2,413 additions & 1,699 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion stories/components/button/tests/button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ButtonBaseExample, { defaultButtonProps } from './examples/button-base';
import ButtonIconOnlyExample, { defaultIconButtonProps } from './examples/button-icon-only';
import ButtonNeighborLocationExample, { defaultButtonNeighborProps } from './examples/button-neighbor-location';
import ButtonWithEllipsisExample, { defaultButtonEllipsisProps } from './examples/button-with-ellipsis';
import { themeArg, THEMES } from './themeUtils.ts';
import { themeArg, THEMES } from './themeUtils';

const meta: Meta = { title: 'Components/Button/Tests' };
export default meta;
Expand Down
2 changes: 1 addition & 1 deletion stories/components/button/tests/examples/button-base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Button from '@semcore/ui/button';
import type { ButtonProps } from '@semcore/ui/button';
import React from 'react';

import { themeFor } from '../themeUtils.ts';
import { themeFor } from '../themeUtils';

type ExampleProps = Exclude<ButtonProps, 'theme' | 'use'> & { style?: any; theme: string };
const Demo = (props: ExampleProps) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { ButtonProps } from '@semcore/ui/button';
import Tooltip, { Hint } from '@semcore/ui/tooltip';
import React from 'react';

import { themeFor } from '../themeUtils.ts';
import { themeFor } from '../themeUtils';

type ExampleProps = Exclude<ButtonProps, 'theme' | 'use'> & { style?: any; theme: string };
const Demo = (props: ExampleProps) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Button from '@semcore/ui/button';
import type { ButtonProps } from '@semcore/ui/button';
import React from 'react';

import { themeFor } from '../themeUtils.ts';
import { themeFor } from '../themeUtils';

type ExampleProps = Exclude<ButtonProps, 'theme' | 'use'> & { style?: any; theme: string };
const Demo = (props: ExampleProps) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Button from '@semcore/ui/button';
import type { ButtonProps } from '@semcore/ui/button';
import React from 'react';

import { themeFor } from '../themeUtils.ts';
import { themeFor } from '../themeUtils';

type ButtonEllipsisProps = ButtonProps & {
ellipsis?: NSText.EllipsisProps;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import DonutMockData from '../../../../../../components/d3-chart/__mocks__/donut
import ScatterplotMockData from '../../../../../../components/d3-chart/__mocks__/scatterplot';
import VennMockData from '../../../../../../components/d3-chart/__mocks__/venn';
import FeedbackRatingFormExample
from '../../../../../ux-patterns/feedback-rating/docs/examples/feedback_rating_form.tsx';
from '../../../../../ux-patterns/feedback-rating/docs/examples/feedback_rating_form';
import PrimaryTable from '../Tables/PrimaryTable';

export type DashboardProps = {
Expand Down
7 changes: 6 additions & 1 deletion tools/builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@
},
"license": "MIT",
"private": true,
"exports": {
"./plugins": "./src/plugins.ts"
},
"dependencies": {
"@semcore/babel-preset-ui": "workspace:*",
"@semcore/esbuild-plugin-semcore": "workspace:*",
"execa": "5.0.0",
"fs-extra": "8.1.0",
"mri": "1.2.0",
"postcss": "8.4.33",
"postcss-cli": "7.1.0",
"postcss-import": "12.0.1",
"postcss-inline-comment": "3.0.0",
"postcss-preset-env": "6.7.0"
"postcss-preset-env": "6.7.0",
"unplugin": "3.0.0"
}
}
9 changes: 9 additions & 0 deletions tools/builder/src/plugins.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { unpluginIcons } from './unplugin-icons.ts';
import { unpluginIllustrations } from './unplugin-illustrations.ts';
import { unpluginSemcoreResolve } from './unplugin-semcore.ts';

export {
unpluginIcons,
unpluginIllustrations,
unpluginSemcoreResolve,
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { resolve as resolvePath, dirname as resolveDirname } from 'path';
import { fileURLToPath } from 'url';
import { resolve as resolvePath } from 'path';

import glob from 'fast-glob';
import { createUnplugin } from 'unplugin';
Expand All @@ -12,18 +11,14 @@ type IconPaths = Record<string, {
};
}>;

const __dirname = resolveDirname(fileURLToPath(import.meta.url));

const iconsDir = resolvePath(__dirname, '../../../../semcore/icon');

export const unpluginIcons = createUnplugin(() => ({
export const unpluginIcons = createUnplugin<{ rootPath: string }>((opts) => ({
name: 'unplugin-icons',
async resolveId(id) {
if (id === '@icons') return id;
},
async load(id) {
if (id !== '@icons') return null;

const iconsDir = resolvePath(opts.rootPath, 'semcore', 'icon');
const fullPath = id.endsWith('/lib') ? resolvePath(iconsDir, 'lib') : resolvePath(iconsDir);
const allIcons = await glob('**/index.mjs', {
cwd: fullPath,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
import { resolve as resolvePath, dirname as resolveDirname } from 'path';
import { fileURLToPath } from 'url';
import { resolve as resolvePath } from 'path';

import { Plugin } from 'esbuild';
import glob from 'fast-glob';
import { createUnplugin } from 'unplugin';

const __dirname = resolveDirname(fileURLToPath(import.meta.url));

const illustrationsDir = resolvePath(__dirname, '../../../../semcore/illustration');

export const unpluginIllustrations = createUnplugin(() => ({
export const unpluginIllustrations = createUnplugin<{ rootPath: string }>((opts) => ({
name: 'unplugin-illustrations',
async resolveId(id) {
if (id === '@illustrations') return id;
},
async load(id) {
if (id !== '@illustrations') return null;
const illustrationsDir = resolvePath(opts.rootPath, 'semcore', 'illustration');
const fullPath = resolvePath(illustrationsDir);
const illustrationPaths = await glob('lib/*/index.mjs', {
cwd: fullPath,
Expand Down
43 changes: 43 additions & 0 deletions tools/builder/src/unplugin-semcore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { loadSemcoreSources, resolveSemcoreSources } from '@semcore/esbuild-plugin-semcore';
import { createUnplugin } from 'unplugin';

import { makeCacheManager } from './cache-manager.ts';

const cacheManager = makeCacheManager('esbuild_plugin_semcore-resolver');

export const unpluginSemcoreResolve = createUnplugin<{ rootPath: string }>((opts) => ({
name: 'semcore-resolve',
async buildStart() {
await cacheManager.init();

if (process.argv.includes('--reset-cache')) {
await cacheManager.reset();
}
},
async resolveId(id) {
if (!id.includes('@semcore') || id.includes('@semcore/theme')) return null;
if (id.endsWith('.md')) return null;
return await resolveSemcoreSources(id, opts.rootPath);
},
loadInclude: (id) => {
return id.includes('/semcore/');
},
async load(id) {
const cache = await cacheManager.hasInCache(id);

if (cache) {
return {
code: cache,
};
}

const { code } = await loadSemcoreSources(id);

await cacheManager.addToCache(id, code);

return {
code,
};
},
enforce: 'pre',
}));
3 changes: 2 additions & 1 deletion tools/builder/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"compilerOptions": {
"module": "esnext",
"target": "esnext"
"target": "esnext",
"allowImportingTsExtensions": true
},
"extends": "../../tsconfig.json",
"include": ["src", "lib", "bin"]
Expand Down
2 changes: 1 addition & 1 deletion tools/continuous-delivery/src/utils/gitUtils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { execSync } from 'child_process';
import process from 'process';

import type { ReleaseVersion } from '@tools/continuous-delivery/src/utils/changelog';
import Git from 'simple-git';

import type { ReleaseVersion } from './changelog';
import { log, prerelaseSuffix } from '../utils';
import { NpmUtils } from './npmUtils';
import type { PackageJson } from './packages';
Expand Down
1 change: 0 additions & 1 deletion tools/esbuild-plugin-semcore/cache-manager.ts

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion tools/esbuild-plugin-semcore/index.ts

This file was deleted.

7 changes: 1 addition & 6 deletions tools/esbuild-plugin-semcore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@
"name": "@semcore/esbuild-plugin-semcore",
"version": "1.0.0",
"exports": {
".": "./src/esbuild-plugin-semcore.ts",
"./esbuild-plugin-semcore-sources-resolve": "./src/esbuild-plugin-semcore-sources-resolve.ts",
"./cache-manager": "./src/cache-manager.ts"
".": "./src/index.ts"
},
"license": "MIT",
"private": true,
"scripts": {
"test": "jest"
},
"devDependencies": {
"@types/babel__core": "^7.20.5",
"esbuild": "0.28.0"
Expand Down
Loading
Loading