Skip to content

Commit babf238

Browse files
feat(custom-element): new es build module (#18762)
* feat(custom-element): new es build module * fix(components): use custom * chore(todo): add to build
1 parent 5d7c05e commit babf238

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
packages/*/build/
44
packages/*/examples/*/build/
55
es
6+
es-custom
67
lib
78
dist
89
umd

packages/web-components/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"custom-elements.json",
1616
"dist/**/*",
1717
"es/**/*",
18+
"es-custom/**/*",
1819
"lib/**/*",
1920
"scss/**/*",
2021
"telemetry.yml"
@@ -40,6 +41,7 @@
4041
},
4142
"./es": "./es/index.js",
4243
"./es/": "./es/",
44+
"./es-custom/*": "./es-custom/*",
4345
"./lib/": "./lib/",
4446
"./dist/": "./dist/",
4547
"./scss/": "./scss/",

packages/web-components/tasks/build.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import nodeResolve from '@rollup/plugin-node-resolve';
2222
import path from 'path';
2323
import postcss from 'postcss';
2424
import typescript from '@rollup/plugin-typescript';
25+
import fs from 'fs-extra';
2526

2627
import * as packageJson from '../package.json' with { type: 'json' };
2728

@@ -91,6 +92,8 @@ async function build() {
9192
sourcemap: true,
9293
});
9394
}
95+
96+
await postBuild();
9497
}
9598

9699
const banner = `/**
@@ -164,3 +167,27 @@ build().catch((error) => {
164167
console.log(error);
165168
process.exit(1);
166169
});
170+
171+
// TODO: remove and add scoped elements!
172+
async function postBuild() {
173+
const sourceDir = path.resolve(__dirname, '../es');
174+
175+
if (sourceDir) {
176+
const targetDir = path.resolve(__dirname, '../es-custom');
177+
178+
// Copy `es` directory to `es-custom`
179+
await fs.copy(sourceDir, targetDir);
180+
181+
// Find all files in the `es-custom` directory
182+
const files = await globby([`${targetDir}/**/*`], { onlyFiles: true });
183+
184+
// Replace "cds" with "cds-custom" in all files
185+
await Promise.all(
186+
files.map(async (file) => {
187+
const content = await fs.promises.readFile(file, 'utf8');
188+
const updatedContent = content.replace(/cds/g, 'cds-custom');
189+
await fs.promises.writeFile(file, updatedContent);
190+
})
191+
);
192+
}
193+
}

0 commit comments

Comments
 (0)