diff --git a/cspell.json b/cspell.json index f9751c3ff94..f9d0945a73b 100644 --- a/cspell.json +++ b/cspell.json @@ -214,6 +214,7 @@ "typeahead", "typeof", "unauthorizedemptystate", + "unbundle", "useravatar", "userprofileimage", "uuidv", diff --git a/packages/ibm-products-styles/src/components/Datagrid/styles/addons/_FilterPanel.scss b/packages/ibm-products-styles/src/components/Datagrid/styles/addons/_FilterPanel.scss index 987f1f55471..d9fca67d0ba 100644 --- a/packages/ibm-products-styles/src/components/Datagrid/styles/addons/_FilterPanel.scss +++ b/packages/ibm-products-styles/src/components/Datagrid/styles/addons/_FilterPanel.scss @@ -21,6 +21,7 @@ initial-value: 320px; syntax: ''; } + $block-class-component: #{$block-class}-filter-panel; .#{$block-class-component} { diff --git a/packages/ibm-products-web-components/package.json b/packages/ibm-products-web-components/package.json index 0a5dd8b19e7..a0ad1751bb6 100644 --- a/packages/ibm-products-web-components/package.json +++ b/packages/ibm-products-web-components/package.json @@ -43,7 +43,7 @@ "web components" ], "scripts": { - "build": "yarn clean && node tasks/build.js && yarn wca", + "build": "yarn clean && tsdown && yarn wca", "build:storybook": "storybook build --quiet", "clean": "rimraf es lib scss dist storybook-static", "postinstall": "ibmtelemetry --config=telemetry.yml", @@ -106,6 +106,7 @@ "sass": "^1.93.2", "storybook": "^9.1.15", "storybook-addon-accessibility-checker": ">=9.2.0-rc.0", + "tsdown": "^0.14.1", "tslib": "^2.8.1", "typescript": "^5.5.3", "vite": "npm:rolldown-vite@latest", diff --git a/packages/ibm-products-web-components/tasks/build.js b/packages/ibm-products-web-components/tasks/build.js deleted file mode 100644 index 8249479a584..00000000000 --- a/packages/ibm-products-web-components/tasks/build.js +++ /dev/null @@ -1,202 +0,0 @@ -/** - * Copyright IBM Corp. 2024 - * - * This source code is licensed under the Apache-2.0 license found in the - * LICENSE file in the root directory of this source tree. - */ - -'use strict'; - -import { fileURLToPath } from 'url'; -import { globby } from 'globby'; -import { rollup } from 'rollup'; -import alias from '@rollup/plugin-alias'; -import autoprefixer from 'autoprefixer'; -import commonjs from '@rollup/plugin-commonjs'; -import copy from 'rollup-plugin-copy'; -import cssnano from 'cssnano'; -import litSCSS from '../tools/rollup-plugin-lit-scss.js'; -import nodeResolve from '@rollup/plugin-node-resolve'; -import path from 'path'; -import postcss from 'postcss'; -import typescript from '@rollup/plugin-typescript'; -import json from '@rollup/plugin-json'; -import image from '@rollup/plugin-image'; -import fs from 'fs-extra'; - -import * as packageJson from '../package.json' with { type: 'json' }; - -const __dirname = path.dirname(fileURLToPath(import.meta.url)); - -async function build() { - const esInputs = await globby([ - 'src/**/*.ts', - '!src/**/*.stories.ts', - '!src/**/*.d.ts', - '!src/polyfills', - ]); - - const libInputs = await globby([ - 'src/components/**/defs.ts', - 'src/globals/**/*.ts', - '!src/globals/decorators/**/*.ts', - '!src/globals/directives/**/*.ts', - '!src/globals/internal/**/*.ts', - '!src/globals/mixins/**/*.ts', - ]); - - const iconInput = await globby([ - '../node_modules/@carbon/icons/lib/**/*.js', - '../../node_modules/@carbon/icons/lib/**/*.js', - '!**/index.js', - ]); - - const entryPoint = { - rootDir: 'src', - outputDirectory: path.resolve(__dirname, '..'), - }; - - const formats = [ - { - type: 'esm', - directory: 'es', - }, - { - type: 'commonjs', - directory: 'lib', - }, - ]; - - for (const format of formats) { - const outputDirectory = path.join( - entryPoint.outputDirectory, - format.directory - ); - - const cwcInputConfig = getRollupConfig( - format.type === 'esm' ? esInputs : libInputs, - entryPoint.rootDir, - outputDirectory, - format.type === 'esm' ? iconInput : [] - ); - - const cwcBundle = await rollup(cwcInputConfig); - - await cwcBundle.write({ - dir: outputDirectory, - format: format.type, - preserveModules: true, - preserveModulesRoot: 'src', - banner, - exports: 'named', - sourcemap: true, - }); - } - - await postBuild(); -} - -const banner = `/** - * Copyright IBM Corp. 2024 - * - * This source code is licensed under the Apache-2.0 license found in the - * LICENSE file in the root directory of this source tree. - */ -`; - -function getRollupConfig(input, rootDir, outDir, iconInput) { - return { - input, - // Mark dependencies listed in `package.json` as external so that they are - // not included in the output bundle. - external: [ - ...Object.keys(packageJson.default.dependencies), - ...Object.keys(packageJson.default.devDependencies), - ].map((name) => { - // Transform the name of each dependency into a regex so that imports from - // nested paths are correctly marked as external. - // - // Example: - // import 'module-name'; - // import 'module-name/path/to/nested/module'; - return new RegExp(`^${name}(/.*)?`); - }), - plugins: [ - alias({ - entries: [{ find: /^(.*)\.scss\?lit$/, replacement: '$1.scss' }], - }), - copy({ - targets: [ - { - src: 'src/components/**/*.scss', - dest: 'scss', - ignore: 'src/components/**/story-styles.scss', - }, - ], - flatten: false, - }), - [json()], - nodeResolve({ - browser: true, - mainFields: ['jsnext', 'module', 'main'], - extensions: ['.js', '.ts'], - }), - commonjs({ - include: [/node_modules/], - }), - litSCSS({ - includePaths: [ - path.resolve(__dirname, '../node_modules'), - path.resolve(__dirname, '../../../node_modules'), - ], - async preprocessor(contents, id) { - return ( - await postcss([autoprefixer(), cssnano()]).process(contents, { - from: id, - }) - ).css; - }, - }), - typescript({ - noEmitOnError: true, - compilerOptions: { - rootDir, - outDir, - }, - }), - image(), - ], - }; -} - -build().catch((error) => { - console.log(error); - process.exit(1); -}); - -async function postBuild() { - const sourceDir = path.resolve(__dirname, '../es'); - - if (sourceDir) { - const targetDir = path.resolve(__dirname, '../es-custom'); - - // Copy `es` directory to `es-custom` - await fs.copy(sourceDir, targetDir); - - // Find all files in the `es-custom` directory - const files = await globby([`${targetDir}/**/*`], { onlyFiles: true }); - - // Replace "cds" with "cds-custom" in all files - await Promise.all( - files.map(async (file) => { - const content = await fs.promises.readFile(file, 'utf8'); - const updatedContent = content.replace(/(?