diff --git a/.yarn/cache/@types-clean-css-npm-4.2.11-2b47418843-385337a881.zip b/.yarn/cache/@types-clean-css-npm-4.2.11-2b47418843-385337a881.zip new file mode 100644 index 00000000000..5ab239db018 Binary files /dev/null and b/.yarn/cache/@types-clean-css-npm-4.2.11-2b47418843-385337a881.zip differ diff --git a/.yarn/cache/@types-html-minifier-npm-3.5.3-48bb59db10-bad3bece7e.zip b/.yarn/cache/@types-html-minifier-npm-3.5.3-48bb59db10-bad3bece7e.zip new file mode 100644 index 00000000000..f422fc14219 Binary files /dev/null and b/.yarn/cache/@types-html-minifier-npm-3.5.3-48bb59db10-bad3bece7e.zip differ diff --git a/.yarn/cache/@types-relateurl-npm-0.2.33-e8ef0a6da2-a4b7876cc2.zip b/.yarn/cache/@types-relateurl-npm-0.2.33-e8ef0a6da2-a4b7876cc2.zip new file mode 100644 index 00000000000..e1bf54dc9e0 Binary files /dev/null and b/.yarn/cache/@types-relateurl-npm-0.2.33-e8ef0a6da2-a4b7876cc2.zip differ diff --git a/.yarn/cache/html-minifier-npm-4.0.0-2c414aaddf-a1a49ee78a.zip b/.yarn/cache/html-minifier-npm-4.0.0-2c414aaddf-a1a49ee78a.zip new file mode 100644 index 00000000000..395d645edfa Binary files /dev/null and b/.yarn/cache/html-minifier-npm-4.0.0-2c414aaddf-a1a49ee78a.zip differ diff --git a/.yarn/cache/minify-html-literals-npm-1.3.5-2818068cad-9f5b50055e.zip b/.yarn/cache/minify-html-literals-npm-1.3.5-2818068cad-9f5b50055e.zip new file mode 100644 index 00000000000..679fff6d7f1 Binary files /dev/null and b/.yarn/cache/minify-html-literals-npm-1.3.5-2818068cad-9f5b50055e.zip differ diff --git a/.yarn/cache/parse-literals-npm-1.2.1-2c41c00bff-8f1ad2ed47.zip b/.yarn/cache/parse-literals-npm-1.2.1-2c41c00bff-8f1ad2ed47.zip new file mode 100644 index 00000000000..d152fed0970 Binary files /dev/null and b/.yarn/cache/parse-literals-npm-1.2.1-2c41c00bff-8f1ad2ed47.zip differ diff --git a/.yarn/cache/rollup-plugin-minify-html-literals-npm-1.2.6-fbf338ecb6-07b9f321dc.zip b/.yarn/cache/rollup-plugin-minify-html-literals-npm-1.2.6-fbf338ecb6-07b9f321dc.zip new file mode 100644 index 00000000000..2f1beac5ca2 Binary files /dev/null and b/.yarn/cache/rollup-plugin-minify-html-literals-npm-1.2.6-fbf338ecb6-07b9f321dc.zip differ diff --git a/packages/carbon-web-components/gulp-tasks/build/modules/scripts.js b/packages/carbon-web-components/gulp-tasks/build/modules/scripts.js index 83e716f8725..4c800da5306 100644 --- a/packages/carbon-web-components/gulp-tasks/build/modules/scripts.js +++ b/packages/carbon-web-components/gulp-tasks/build/modules/scripts.js @@ -1,7 +1,7 @@ /** * @license * - * Copyright IBM Corp. 2020, 2022 + * Copyright IBM Corp. 2020, 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. @@ -38,22 +38,6 @@ function scripts() { // `version` field ensures `@babel/plugin-transform-runtime` is applied to newer helpers like decorator plugins: [ ['@babel/plugin-transform-runtime', { useESModules: true, version: '7.8.0' }], - [ - 'template-html-minifier', - { - modules: { - 'lit-html': ['html'], - 'lit-element': ['html'], - }, - htmlMinifier: { - collapseWhitespace: true, - conservativeCollapse: true, - removeComments: true, - caseSensitive: true, - minifyCSS: true, - }, - }, - ], babelPluginResourceJSPaths, ], }) diff --git a/packages/carbon-web-components/package.json b/packages/carbon-web-components/package.json index 648cea5c11c..43191e0931b 100644 --- a/packages/carbon-web-components/package.json +++ b/packages/carbon-web-components/package.json @@ -192,6 +192,7 @@ "replace-ext": "^2.0.0", "resize-observer-polyfill": "^1.5.0", "rollup": "^2.55.1", + "rollup-plugin-minify-html-literals": "^1.2.6", "rollup-plugin-multi-input": "^1.3.1", "rtlcss": "^3.0.0", "sass": "~1.62.0", diff --git a/packages/carbon-web-components/tools/get-rollup-config.js b/packages/carbon-web-components/tools/get-rollup-config.js index f11c495a585..c81c889e130 100644 --- a/packages/carbon-web-components/tools/get-rollup-config.js +++ b/packages/carbon-web-components/tools/get-rollup-config.js @@ -1,7 +1,7 @@ /** * @license * - * Copyright IBM Corp. 2020, 2022 + * Copyright IBM Corp. 2020, 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. @@ -20,6 +20,8 @@ const { nodeResolve } = require('@rollup/plugin-node-resolve'); const rtlcss = require('rtlcss'); const { promisify } = require('util'); const { terser } = require('rollup-plugin-terser'); +const minifyHTMLLiterals = + require('rollup-plugin-minify-html-literals').default; const carbonIcons = require('./rollup-plugin-icons'); const fixHostPseudo = require('./postcss-fix-host-pseudo'); @@ -129,6 +131,17 @@ function getRollupConfig({ include: [/node_modules/], sourceMap: true, }), + minifyHTMLLiterals({ + failOnError: true, + options: { + minifyOptions: { + caseSensitive: true, + collapseInlineTagWhitespace: true, + collapseWhitespace: true, + removeComments: true, + }, + }, + }), carbonIcons(), babel.babel({ babelHelpers: 'runtime', @@ -142,29 +155,9 @@ function getRollupConfig({ '@babel/plugin-proposal-decorators', { decoratorsBeforeExport: true }, ], - '@babel/plugin-proposal-nullish-coalescing-operator', - ['@babel/plugin-proposal-object-rest-spread', { useBuiltIns: true }], - '@babel/plugin-proposal-optional-chaining', - ...(mode === 'development' - ? [] - : [ - [ - 'template-html-minifier', - { - modules: { - 'lit-html': ['html'], - 'lit-element': ['html'], - }, - htmlMinifier: { - collapseWhitespace: true, - conservativeCollapse: true, - removeComments: true, - caseSensitive: true, - minifyCSS: true, - }, - }, - ], - ]), + '@babel/plugin-transform-nullish-coalescing-operator', + ['@babel/plugin-transform-object-rest-spread', { useBuiltIns: true }], + '@babel/plugin-transform-optional-chaining', ], }), litSCSS({ diff --git a/packages/web-components/package.json b/packages/web-components/package.json index 666a6d6f29c..0d8aa51d44b 100644 --- a/packages/web-components/package.json +++ b/packages/web-components/package.json @@ -221,6 +221,7 @@ "rollup": "^2.55.1", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-inject-process-env": "^1.3.1", + "rollup-plugin-minify-html-literals": "^1.2.6", "rollup-plugin-multi-input": "^1.3.1", "rollup-plugin-sizes": "^1.0.4", "rtlcss": "^3.0.0", diff --git a/packages/web-components/src/components/table-of-contents/table-of-contents.ts b/packages/web-components/src/components/table-of-contents/table-of-contents.ts index 461f144f55d..4804360ba8a 100644 --- a/packages/web-components/src/components/table-of-contents/table-of-contents.ts +++ b/packages/web-components/src/components/table-of-contents/table-of-contents.ts @@ -1,7 +1,7 @@ /** * @license * - * Copyright IBM Corp. 2020, 2023 + * Copyright IBM Corp. 2020, 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. @@ -858,9 +858,7 @@ class DDSTableOfContents extends HostListenerMixin(
+ style="inset-inline-start: -${currentScrollPosition}px"> ${pageIsRTL ? html`
` : html`
`} diff --git a/packages/web-components/tests/snapshots/dds-table-of-contents.md b/packages/web-components/tests/snapshots/dds-table-of-contents.md index 38652ea7897..74d2b48eb57 100644 --- a/packages/web-components/tests/snapshots/dds-table-of-contents.md +++ b/packages/web-components/tests/snapshots/dds-table-of-contents.md @@ -29,7 +29,7 @@
@@ -84,7 +84,7 @@
@@ -133,7 +133,7 @@
diff --git a/packages/web-components/tools/get-rollup-config.js b/packages/web-components/tools/get-rollup-config.js index a2438d14641..afbddd4f6d2 100644 --- a/packages/web-components/tools/get-rollup-config.js +++ b/packages/web-components/tools/get-rollup-config.js @@ -1,7 +1,7 @@ /** * @license * - * Copyright IBM Corp. 2020, 2023 + * Copyright IBM Corp. 2020, 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. @@ -24,6 +24,8 @@ const replace = require('@rollup/plugin-replace'); const { terser } = require('rollup-plugin-terser'); const multiInput = require('rollup-plugin-multi-input').default; const injectProcessEnv = require('rollup-plugin-inject-process-env'); +const minifyHTMLLiterals = + require('rollup-plugin-minify-html-literals').default; const ibmdotcomIcon = require('./rollup-plugin-ibmdotcom-icon'); const litSCSS = require('./rollup-plugin-lit-scss'); @@ -164,6 +166,17 @@ function getRollupConfig({ include: [/node_modules/], sourceMap: true, }), + minifyHTMLLiterals({ + failOnError: true, + options: { + minifyOptions: { + caseSensitive: true, + collapseInlineTagWhitespace: true, + collapseWhitespace: true, + removeComments: true, + }, + }, + }), ibmdotcomIcon(), injectProcessEnv( { @@ -187,29 +200,9 @@ function getRollupConfig({ '@babel/plugin-proposal-decorators', { decoratorsBeforeExport: true }, ], - '@babel/plugin-proposal-nullish-coalescing-operator', - ['@babel/plugin-proposal-object-rest-spread', { useBuiltIns: true }], - '@babel/plugin-proposal-optional-chaining', - ...(mode === 'development' - ? [] - : [ - [ - 'template-html-minifier', - { - modules: { - 'lit-html': ['html'], - 'lit-element': ['html'], - }, - htmlMinifier: { - collapseWhitespace: true, - conservativeCollapse: true, - removeComments: true, - caseSensitive: true, - minifyCSS: true, - }, - }, - ], - ]), + '@babel/plugin-transform-nullish-coalescing-operator', + ['@babel/plugin-transform-object-rest-spread', { useBuiltIns: true }], + '@babel/plugin-transform-optional-chaining', ], }), // We are using `carbon-web-components` code merely as the source of inheritance, diff --git a/yarn.lock b/yarn.lock index f2e0c0c7a04..4abaea06d49 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2683,6 +2683,7 @@ __metadata: rollup: ^2.55.1 rollup-plugin-analyzer: ^4.0.0 rollup-plugin-inject-process-env: ^1.3.1 + rollup-plugin-minify-html-literals: ^1.2.6 rollup-plugin-multi-input: ^1.3.1 rollup-plugin-sizes: ^1.0.4 rtlcss: ^3.0.0 @@ -2983,6 +2984,7 @@ __metadata: replace-ext: ^2.0.0 resize-observer-polyfill: ^1.5.0 rollup: ^2.55.1 + rollup-plugin-minify-html-literals: ^1.2.6 rollup-plugin-multi-input: ^1.3.1 rtlcss: ^3.0.0 sass: ~1.62.0 @@ -7016,6 +7018,16 @@ __metadata: languageName: node linkType: hard +"@types/clean-css@npm:*": + version: 4.2.11 + resolution: "@types/clean-css@npm:4.2.11" + dependencies: + "@types/node": "npm:*" + source-map: "npm:^0.6.0" + checksum: 385337a881c7870664d8987f12b9c814d835104dcf5f1737b74ab759ca68424ce93636cbff73ea9c41290c3dc2a92a4cc6246869bd9982255cfa28dcc2ccec93 + languageName: node + linkType: hard + "@types/clone@npm:^0.1.29": version: 0.1.30 resolution: "@types/clone@npm:0.1.30" @@ -7194,6 +7206,17 @@ __metadata: languageName: node linkType: hard +"@types/html-minifier@npm:^3.5.3": + version: 3.5.3 + resolution: "@types/html-minifier@npm:3.5.3" + dependencies: + "@types/clean-css": "npm:*" + "@types/relateurl": "npm:*" + "@types/uglify-js": "npm:*" + checksum: bad3bece7ec0c29d81266a5884ade79a6d6fb5c10b9a7b79e17dae13290052776a1a5a571125fd5f47e396cd45304eafaec41b68bf42d0dd765356cf77a6e088 + languageName: node + linkType: hard + "@types/http-errors@npm:*": version: 2.0.1 resolution: "@types/http-errors@npm:2.0.1" @@ -7567,6 +7590,13 @@ __metadata: languageName: node linkType: hard +"@types/relateurl@npm:*": + version: 0.2.33 + resolution: "@types/relateurl@npm:0.2.33" + checksum: a4b7876cc24da3eddc1202d9f57fb6cdd551ff3d884124365dd15012dde20c2b4c19eee9bcd3b17e7c43e8edbe82a33753a6c266e41e3761283d44e6234d47da + languageName: node + linkType: hard + "@types/resolve@npm:1.17.1": version: 1.17.1 resolution: "@types/resolve@npm:1.17.1" @@ -11202,7 +11232,7 @@ __metadata: languageName: node linkType: hard -"camel-case@npm:3.0.x": +"camel-case@npm:3.0.x, camel-case@npm:^3.0.0": version: 3.0.0 resolution: "camel-case@npm:3.0.0" dependencies: @@ -18831,6 +18861,23 @@ __metadata: languageName: node linkType: hard +"html-minifier@npm:^4.0.0": + version: 4.0.0 + resolution: "html-minifier@npm:4.0.0" + dependencies: + camel-case: "npm:^3.0.0" + clean-css: "npm:^4.2.1" + commander: "npm:^2.19.0" + he: "npm:^1.2.0" + param-case: "npm:^2.1.1" + relateurl: "npm:^0.2.7" + uglify-js: "npm:^3.5.1" + bin: + html-minifier: ./cli.js + checksum: a1a49ee78a41eb3232f7aa51be25092d7634548e8996577b2bdab22dc9ac736594d35aab7fdf81fb5a0da11f7bc688f500c297b24fd312d48c0ce8739ed4f06f + languageName: node + linkType: hard + "html-tags@npm:^3.1.0": version: 3.3.1 resolution: "html-tags@npm:3.3.1" @@ -23585,7 +23632,7 @@ __metadata: languageName: node linkType: hard -"magic-string@npm:^0.25.7": +"magic-string@npm:^0.25.0, magic-string@npm:^0.25.7": version: 0.25.9 resolution: "magic-string@npm:0.25.9" dependencies: @@ -24464,6 +24511,19 @@ __metadata: languageName: node linkType: hard +"minify-html-literals@npm:^1.3.5": + version: 1.3.5 + resolution: "minify-html-literals@npm:1.3.5" + dependencies: + "@types/html-minifier": "npm:^3.5.3" + clean-css: "npm:^4.2.1" + html-minifier: "npm:^4.0.0" + magic-string: "npm:^0.25.0" + parse-literals: "npm:^1.2.1" + checksum: 9f5b50055e0df5763463f37136418af5a143169ffa1bafdc73571ab36563e5c49e4bf5068f7cc2cecd80b07d974e467e3879e750139e14c400b99843e9c23737 + languageName: node + linkType: hard + "minimalistic-assert@npm:^1.0.0, minimalistic-assert@npm:^1.0.1": version: 1.0.1 resolution: "minimalistic-assert@npm:1.0.1" @@ -26456,7 +26516,7 @@ __metadata: languageName: node linkType: hard -"param-case@npm:2.1.x": +"param-case@npm:2.1.x, param-case@npm:^2.1.1": version: 2.1.1 resolution: "param-case@npm:2.1.1" dependencies: @@ -26578,6 +26638,15 @@ __metadata: languageName: node linkType: hard +"parse-literals@npm:^1.2.1": + version: 1.2.1 + resolution: "parse-literals@npm:1.2.1" + dependencies: + typescript: "npm:^2.9.2 || ^3.0.0 || ^4.0.0" + checksum: 8f1ad2ed47887b555a909a402d47dfa94d57adc5f3f70b10543618eebfd77912295e54989971a580d4704994e498263ec2a2ceb0ed53fdd1a3b57449254f094e + languageName: node + linkType: hard + "parse-node-version@npm:^1.0.0": version: 1.0.1 resolution: "parse-node-version@npm:1.0.1" @@ -30162,6 +30231,18 @@ __metadata: languageName: node linkType: hard +"rollup-plugin-minify-html-literals@npm:^1.2.6": + version: 1.2.6 + resolution: "rollup-plugin-minify-html-literals@npm:1.2.6" + dependencies: + minify-html-literals: "npm:^1.3.5" + rollup-pluginutils: "npm:^2.8.2" + peerDependencies: + rollup: ^0.65.2 || ^1.0.0 || ^2.0.0 + checksum: 07b9f321dc4de648313cf185737ea7ab4d5a6c4a10639944d3823d9c419cd5c73b486e02d9af6e013cafbd753d02d5ca9991a8c01c96e2d2a62b55bd5fdaa4dd + languageName: node + linkType: hard + "rollup-plugin-multi-input@npm:^1.3.1": version: 1.4.1 resolution: "rollup-plugin-multi-input@npm:1.4.1" @@ -30232,7 +30313,7 @@ __metadata: languageName: node linkType: hard -"rollup-pluginutils@npm:^2.3.3": +"rollup-pluginutils@npm:^2.3.3, rollup-pluginutils@npm:^2.8.2": version: 2.8.2 resolution: "rollup-pluginutils@npm:2.8.2" dependencies: @@ -33535,7 +33616,7 @@ __metadata: languageName: node linkType: hard -"typescript@npm:^3 || ^4, typescript@npm:^4.4.3": +"typescript@npm:^2.9.2 || ^3.0.0 || ^4.0.0, typescript@npm:^3 || ^4, typescript@npm:^4.4.3": version: 4.9.5 resolution: "typescript@npm:4.9.5" bin: @@ -33565,7 +33646,7 @@ __metadata: languageName: node linkType: hard -"typescript@patch:typescript@^3 || ^4#~builtin, typescript@patch:typescript@^4.4.3#~builtin": +"typescript@patch:typescript@^3 || ^4#~builtin, typescript@patch:typescript@^4.4.3#~builtin, typescript@patch:typescript@npm%3A^2.9.2 || ^3.0.0 || ^4.0.0#~builtin": version: 4.9.5 resolution: "typescript@patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=289587" bin: @@ -33621,7 +33702,7 @@ __metadata: languageName: node linkType: hard -"uglify-js@npm:^3.1.4": +"uglify-js@npm:^3.1.4, uglify-js@npm:^3.5.1": version: 3.17.4 resolution: "uglify-js@npm:3.17.4" bin: