Przeglądaj źródła

chore: adjusted the turbo.json file to clean, then build svgs and scss before compiling TS code

benduran 4 tygodni temu
rodzic
commit
ef3d9f8882

+ 47 - 23
packages/build-ts-package/src/build-ts-package.js

@@ -100,8 +100,8 @@ export async function buildTsPackage(argv = process.argv) {
 
   const outDirPath = path.isAbsolute(outDir) ? outDir : path.join(cwd, outDir);
 
-  /** @type {import('tsdown').Format} */
-  const format = [noCjs ? undefined : "cjs", noEsm ? undefined : "esm"].filter(
+  /** @type {import('tsdown').Format[]} */
+  const formats = [noCjs ? undefined : "cjs", noEsm ? undefined : "esm"].filter(
     (format) => Boolean(format),
   );
 
@@ -111,27 +111,51 @@ export async function buildTsPackage(argv = process.argv) {
     throw new Error(`unable to build ${cwd} because no tsconfig was found`);
   }
 
-  await build({
-    dts: !noDts,
-    entry: [
-      "./src/**/*.ts",
-      "./src/**/*.tsx",
-      // ignore all storybook entrypoints
-      "!./src/**/*.stories.ts",
-      "!./src/**/*.stories.tsx",
-      "!./src/**/*.stories.mdx",
-    ],
-    exports: all ? { all: true } : true,
-    // do not attempt to resolve or import CSS, SCSS or SVG files
-    external: [/\.s?css$/, /\.svg$/],
-    format,
-    outDir: outDirPath,
-    platform: "neutral",
-    plugins: [],
-    tsconfig,
-    unbundle: true,
-    watch,
-  });
+  await Promise.all(
+    formats.map((format) =>
+      build({
+        clean: false,
+        dts: !noDts,
+        entry: [
+          "./src/**/*.ts",
+          "./src/**/*.tsx",
+          // ignore all storybook entrypoints
+          "!./src/**/*.stories.ts",
+          "!./src/**/*.stories.tsx",
+          "!./src/**/*.stories.mdx",
+        ],
+        exports: all ? { all: true } : true,
+        // do not attempt to resolve or import CSS, SCSS or SVG files
+        external: [/\.s?css$/, /\.svg$/],
+        format,
+        outDir: path.join(outDirPath, format),
+        platform: "neutral",
+        tsconfig,
+        unbundle: true,
+        watch,
+      }),
+    ),
+  );
+  // await build({
+  //   dts: !noDts,
+  //   entry: [
+  //     "./src/**/*.ts",
+  //     "./src/**/*.tsx",
+  //     // ignore all storybook entrypoints
+  //     "!./src/**/*.stories.ts",
+  //     "!./src/**/*.stories.tsx",
+  //     "!./src/**/*.stories.mdx",
+  //   ],
+  //   exports: all ? { all: true } : true,
+  //   // do not attempt to resolve or import CSS, SCSS or SVG files
+  //   external: [/\.s?css$/, /\.svg$/],
+  //   format,
+  //   outDir: outDirPath,
+  //   platform: "neutral",
+  //   tsconfig,
+  //   unbundle: true,
+  //   watch,
+  // });
 }
 
 await buildTsPackage();

+ 74 - 74
packages/component-library/package.json

@@ -8,87 +8,87 @@
     "pnpm": ">=10.19.0"
   },
   "exports": {
-    "./AppShell": "./dist/AppShell/index.js",
-    "./AppShell/amplitude": "./dist/AppShell/amplitude.js",
-    "./AppShell/body-providers": "./dist/AppShell/body-providers.js",
-    "./AppShell/fonts": "./dist/AppShell/fonts.js",
-    "./AppShell/html-with-lang": "./dist/AppShell/html-with-lang.js",
-    "./AppShell/i18n-provider": "./dist/AppShell/i18n-provider.js",
-    "./AppShell/report-accessibility": "./dist/AppShell/report-accessibility.js",
-    "./AppShell/router-provider": "./dist/AppShell/router-provider.js",
-    "./AppShell/tabs": "./dist/AppShell/tabs.js",
-    "./Badge": "./dist/Badge/index.js",
-    "./Breadcrumbs": "./dist/Breadcrumbs/index.js",
-    "./Button": "./dist/Button/index.js",
-    "./Card": "./dist/Card/index.js",
-    "./compose-providers": "./dist/compose-providers.js",
-    "./CopyButton": "./dist/CopyButton/index.js",
-    "./CrossfadeTabPanels": "./dist/CrossfadeTabPanels/index.js",
-    "./DropdownCaretDown": "./dist/DropdownCaretDown/index.js",
-    "./EntityList": "./dist/EntityList/index.js",
-    "./ErrorPage": "./dist/ErrorPage/index.js",
-    "./Footer": "./dist/Footer/index.js",
-    "./Header": "./dist/Header/index.js",
-    "./Header/theme-switch": "./dist/Header/theme-switch.js",
-    "./InfoBox": "./dist/InfoBox/index.js",
-    "./Link": "./dist/Link/index.js",
-    "./MainNavTabs": "./dist/MainNavTabs/index.js",
-    "./Meter": "./dist/Meter/index.js",
-    "./MobileNavTabs": "./dist/MobileNavTabs/index.js",
-    "./ModalDialog": "./dist/ModalDialog/index.js",
-    "./NoResults": "./dist/NoResults/index.js",
-    "./NotFoundPage": "./dist/NotFoundPage/index.js",
-    "./omit-keys": "./dist/omit-keys.js",
-    "./overlay-visible-context": "./dist/overlay-visible-context.js",
-    "./Paginator": "./dist/Paginator/index.js",
-    "./SearchButton": "./dist/SearchButton/index.js",
-    "./SearchInput": "./dist/SearchInput/index.js",
-    "./Select": "./dist/Select/index.js",
-    "./SingleToggleGroup": "./dist/SingleToggleGroup/index.js",
-    "./Skeleton": "./dist/Skeleton/index.js",
-    "./social-links": "./dist/social-links.js",
-    "./Spinner": "./dist/Spinner/index.js",
-    "./StatCard": "./dist/StatCard/index.js",
-    "./Status": "./dist/Status/index.js",
-    "./Switch": "./dist/Switch/index.js",
-    "./SymbolPairTag": "./dist/SymbolPairTag/index.js",
-    "./Table": "./dist/Table/index.js",
-    "./TableGrid": "./dist/TableGrid/index.js",
-    "./TableGrid/dummy-row-data": "./dist/TableGrid/dummy-row-data.js",
-    "./TableGrid/table-grid-props": "./dist/TableGrid/table-grid-props.js",
-    "./TabList": "./dist/TabList/index.js",
-    "./Term": "./dist/Term/index.js",
-    "./unstyled/Breadcrumbs": "./dist/unstyled/Breadcrumbs/index.js",
-    "./unstyled/Button": "./dist/unstyled/Button/index.js",
-    "./unstyled/Dialog": "./dist/unstyled/Dialog/index.js",
-    "./unstyled/GridList": "./dist/unstyled/GridList/index.js",
-    "./unstyled/Label": "./dist/unstyled/Label/index.js",
-    "./unstyled/Link": "./dist/unstyled/Link/index.js",
-    "./unstyled/ListBox": "./dist/unstyled/ListBox/index.js",
-    "./unstyled/Meter": "./dist/unstyled/Meter/index.js",
-    "./unstyled/Popover": "./dist/unstyled/Popover/index.js",
-    "./unstyled/SearchField": "./dist/unstyled/SearchField/index.js",
-    "./unstyled/Select": "./dist/unstyled/Select/index.js",
-    "./unstyled/Switch": "./dist/unstyled/Switch/index.js",
-    "./unstyled/Table": "./dist/unstyled/Table/index.js",
-    "./unstyled/Tabs": "./dist/unstyled/Tabs/index.js",
-    "./unstyled/TextField": "./dist/unstyled/TextField/index.js",
-    "./unstyled/Toolbar": "./dist/unstyled/Toolbar/index.js",
-    "./use-prefetch": "./dist/use-prefetch.js",
-    "./useAlert": "./dist/useAlert/index.js",
-    "./useData": "./dist/useData/index.js",
-    "./useDrawer": "./dist/useDrawer/index.js",
-    "./useLogger": "./dist/useLogger/index.js",
-    "./useQueryParamsPagination": "./dist/useQueryParamsPagination/index.js",
-    "./Virtualizer": "./dist/Virtualizer/index.js",
+    "./AppShell": "./dist/esm/AppShell/index.js",
+    "./AppShell/amplitude": "./dist/esm/AppShell/amplitude.js",
+    "./AppShell/body-providers": "./dist/esm/AppShell/body-providers.js",
+    "./AppShell/fonts": "./dist/esm/AppShell/fonts.js",
+    "./AppShell/html-with-lang": "./dist/esm/AppShell/html-with-lang.js",
+    "./AppShell/i18n-provider": "./dist/esm/AppShell/i18n-provider.js",
+    "./AppShell/report-accessibility": "./dist/esm/AppShell/report-accessibility.js",
+    "./AppShell/router-provider": "./dist/esm/AppShell/router-provider.js",
+    "./AppShell/tabs": "./dist/esm/AppShell/tabs.js",
+    "./Badge": "./dist/esm/Badge/index.js",
+    "./Breadcrumbs": "./dist/esm/Breadcrumbs/index.js",
+    "./Button": "./dist/esm/Button/index.js",
+    "./Card": "./dist/esm/Card/index.js",
+    "./compose-providers": "./dist/esm/compose-providers.js",
+    "./CopyButton": "./dist/esm/CopyButton/index.js",
+    "./CrossfadeTabPanels": "./dist/esm/CrossfadeTabPanels/index.js",
+    "./DropdownCaretDown": "./dist/esm/DropdownCaretDown/index.js",
+    "./EntityList": "./dist/esm/EntityList/index.js",
+    "./ErrorPage": "./dist/esm/ErrorPage/index.js",
+    "./Footer": "./dist/esm/Footer/index.js",
+    "./Header": "./dist/esm/Header/index.js",
+    "./Header/theme-switch": "./dist/esm/Header/theme-switch.js",
+    "./InfoBox": "./dist/esm/InfoBox/index.js",
+    "./Link": "./dist/esm/Link/index.js",
+    "./MainNavTabs": "./dist/esm/MainNavTabs/index.js",
+    "./Meter": "./dist/esm/Meter/index.js",
+    "./MobileNavTabs": "./dist/esm/MobileNavTabs/index.js",
+    "./ModalDialog": "./dist/esm/ModalDialog/index.js",
+    "./NoResults": "./dist/esm/NoResults/index.js",
+    "./NotFoundPage": "./dist/esm/NotFoundPage/index.js",
+    "./omit-keys": "./dist/esm/omit-keys.js",
+    "./overlay-visible-context": "./dist/esm/overlay-visible-context.js",
+    "./Paginator": "./dist/esm/Paginator/index.js",
+    "./SearchButton": "./dist/esm/SearchButton/index.js",
+    "./SearchInput": "./dist/esm/SearchInput/index.js",
+    "./Select": "./dist/esm/Select/index.js",
+    "./SingleToggleGroup": "./dist/esm/SingleToggleGroup/index.js",
+    "./Skeleton": "./dist/esm/Skeleton/index.js",
+    "./social-links": "./dist/esm/social-links.js",
+    "./Spinner": "./dist/esm/Spinner/index.js",
+    "./StatCard": "./dist/esm/StatCard/index.js",
+    "./Status": "./dist/esm/Status/index.js",
+    "./Switch": "./dist/esm/Switch/index.js",
+    "./SymbolPairTag": "./dist/esm/SymbolPairTag/index.js",
+    "./Table": "./dist/esm/Table/index.js",
+    "./TableGrid": "./dist/esm/TableGrid/index.js",
+    "./TableGrid/dummy-row-data": "./dist/esm/TableGrid/dummy-row-data.js",
+    "./TableGrid/table-grid-props": "./dist/esm/TableGrid/table-grid-props.js",
+    "./TabList": "./dist/esm/TabList/index.js",
+    "./Term": "./dist/esm/Term/index.js",
+    "./unstyled/Breadcrumbs": "./dist/esm/unstyled/Breadcrumbs/index.js",
+    "./unstyled/Button": "./dist/esm/unstyled/Button/index.js",
+    "./unstyled/Dialog": "./dist/esm/unstyled/Dialog/index.js",
+    "./unstyled/GridList": "./dist/esm/unstyled/GridList/index.js",
+    "./unstyled/Label": "./dist/esm/unstyled/Label/index.js",
+    "./unstyled/Link": "./dist/esm/unstyled/Link/index.js",
+    "./unstyled/ListBox": "./dist/esm/unstyled/ListBox/index.js",
+    "./unstyled/Meter": "./dist/esm/unstyled/Meter/index.js",
+    "./unstyled/Popover": "./dist/esm/unstyled/Popover/index.js",
+    "./unstyled/SearchField": "./dist/esm/unstyled/SearchField/index.js",
+    "./unstyled/Select": "./dist/esm/unstyled/Select/index.js",
+    "./unstyled/Switch": "./dist/esm/unstyled/Switch/index.js",
+    "./unstyled/Table": "./dist/esm/unstyled/Table/index.js",
+    "./unstyled/Tabs": "./dist/esm/unstyled/Tabs/index.js",
+    "./unstyled/TextField": "./dist/esm/unstyled/TextField/index.js",
+    "./unstyled/Toolbar": "./dist/esm/unstyled/Toolbar/index.js",
+    "./use-prefetch": "./dist/esm/use-prefetch.js",
+    "./useAlert": "./dist/esm/useAlert/index.js",
+    "./useData": "./dist/esm/useData/index.js",
+    "./useDrawer": "./dist/esm/useDrawer/index.js",
+    "./useLogger": "./dist/esm/useLogger/index.js",
+    "./useQueryParamsPagination": "./dist/esm/useQueryParamsPagination/index.js",
+    "./Virtualizer": "./dist/esm/Virtualizer/index.js",
     "./package.json": "./package.json"
   },
   "scripts": {
     "build": "build-ts-package --noCjs",
-    "build:declarations": "tsc --project tsconfig.build.json --outDir ./dist/esm",
     "build:scss": "copyfiles -u 1 \"src/**/*.scss\" dist/esm",
     "build:storybook": "storybook build",
     "build:svg": "copyfiles -u 1 \"src/**/*.svg\" dist/esm",
+    "clean": "rm -rf ./dist",
     "fix:format": "prettier --write .",
     "fix:lint:eslint": "eslint --fix .",
     "fix:lint:stylelint": "stylelint --fix 'src/**/*.scss'",

+ 16 - 10
turbo.json

@@ -51,12 +51,26 @@
     "//#test:integration": {
       "dependsOn": ["//#install:modules", "^build"]
     },
+    "clean": {
+      "cache": false,
+      "outputs": []
+    },
+    "build:scss": {
+      "outputs": ["dist/esm/**/*.scss"],
+      "cache": false
+    },
+    "build:svg": {
+      "outputs": ["dist/esm/**/*.svg"],
+      "cache": false
+    },
     "build": {
       "dependsOn": [
         "//#install:modules",
         "pull:env",
         "^build",
-        "clean"
+        "clean",
+        "build:scss",
+        "build:svg"
       ],
       "inputs": [
         "$TURBO_DEFAULT$",
@@ -70,11 +84,7 @@
       "outputs": ["lib/**", "dist/**", ".next/**", "!.next/cache/**"]
     },
     "build:vercel": {
-      "dependsOn": [
-        "//#install:modules",
-        "pull:env",
-        "^build"
-      ],
+      "dependsOn": ["//#install:modules", "pull:env", "^build"],
       "inputs": [
         "$TURBO_DEFAULT$",
         "!README.md",
@@ -86,10 +96,6 @@
       ],
       "outputs": ["lib/**", "dist/**", ".next/**", "!.next/cache/**"]
     },
-    "clean": {
-      "cache": false,
-      "outputs": []
-    },
     "fix": {
       "dependsOn": ["fix:lint", "fix:format"],
       "cache": false