mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
build(scripts): convert to ESM
This commit is contained in:
parent
b9f0332a84
commit
c8ec0ad7d3
3 changed files with 48 additions and 49 deletions
|
@ -1,10 +1,10 @@
|
||||||
const fs = require("node:fs");
|
// @ts-check
|
||||||
const path = require("node:path");
|
import fs from "node:fs";
|
||||||
const sass = require("sass");
|
import path from "node:path";
|
||||||
const autoprefixer = require("autoprefixer");
|
import sass from "sass";
|
||||||
const postcss = require("postcss");
|
import autoprefixer from "autoprefixer";
|
||||||
|
import postcss from "postcss";
|
||||||
|
|
||||||
(async () => {
|
|
||||||
const scss = fs
|
const scss = fs
|
||||||
.readdirSync("css")
|
.readdirSync("css")
|
||||||
.filter((file) => file.endsWith(".scss") && !/^\_popover/.test(file))
|
.filter((file) => file.endsWith(".scss") && !/^\_popover/.test(file))
|
||||||
|
@ -32,4 +32,3 @@ const postcss = require("postcss");
|
||||||
|
|
||||||
fs.writeFileSync(outFile, prefixed.css);
|
fs.writeFileSync(outFile, prefixed.css);
|
||||||
}
|
}
|
||||||
})();
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
const fs = require("node:fs");
|
// @ts-check
|
||||||
const { globSync }= require("tinyglobby");
|
import fs from "node:fs";
|
||||||
const { sveld } = require("sveld");
|
import { globSync } from "tinyglobby";
|
||||||
const pkg = require("../package.json");
|
import { sveld } from "sveld";
|
||||||
|
import pkg from "../package.json" assert { type: "json" };
|
||||||
|
|
||||||
sveld({
|
sveld({
|
||||||
glob: true,
|
glob: true,
|
||||||
|
|
|
@ -1,26 +1,25 @@
|
||||||
const fs = require("node:fs");
|
// @ts-check
|
||||||
const path = require("node:path");
|
import fs from "node:fs";
|
||||||
|
import path from "node:path";
|
||||||
const packagePath = path.join(process.cwd(), "package.json");
|
import pkg from "../package.json" assert { type: "json" };
|
||||||
const package = JSON.parse(fs.readFileSync(packagePath, "utf8"));
|
|
||||||
|
|
||||||
|
/** @type {Array<keyof typeof pkg>} */
|
||||||
const keys_to_remove = ["prettier", "standard-version", "devDependencies"];
|
const keys_to_remove = ["prettier", "standard-version", "devDependencies"];
|
||||||
const scripts_to_keep = ["postinstall"];
|
|
||||||
|
|
||||||
for (const key of keys_to_remove) {
|
for (const key of keys_to_remove) {
|
||||||
delete package[key];
|
delete pkg[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (package.scripts) {
|
/** @type {Set<keyof typeof pkg.scripts>} */
|
||||||
const preserved_scripts = {};
|
const scripts_to_keep = new Set(["postinstall"]);
|
||||||
|
|
||||||
for (const script of scripts_to_keep) {
|
for (const script in pkg.scripts) {
|
||||||
if (package.scripts[script]) {
|
// @ts-ignore
|
||||||
preserved_scripts[script] = package.scripts[script];
|
if (!scripts_to_keep.has(script)) {
|
||||||
|
delete pkg.scripts[script];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
package.scripts = preserved_scripts;
|
// Write the updated package.json file.
|
||||||
}
|
const pkgPath = path.join(process.cwd(), "package.json");
|
||||||
|
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
|
||||||
fs.writeFileSync(packagePath, JSON.stringify(package, null, 2) + "\n");
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue