build: convert cjs to esm

This commit is contained in:
metonym 2021-09-01 13:07:11 -07:00
commit 778c469b6d
2 changed files with 21 additions and 22 deletions

View file

@ -1,20 +1,19 @@
const fs = require("fs");
const path = require("path");
const glob = require("glob");
const pkg = require("../package.json");
import fs from "fs";
import path from "path";
import glob from "glob";
function buildApi() {
const components = {};
const pkg = JSON.parse(
fs.readFileSync(new URL("../package.json", import.meta.url), "utf8")
);
glob.sync("src/**/*.svelte").forEach((file) => {
const { name } = path.parse(file);
components[name] = { path: path.join(pkg.name, file) };
});
const components = {};
fs.writeFileSync(
"preprocess/api.json",
JSON.stringify({ version: pkg.version, components }, null, 2)
);
}
glob.sync("src/**/*.svelte").forEach((file) => {
const { name } = path.parse(file);
components[name] = { path: path.join(pkg.name, file) };
});
buildApi();
fs.writeFileSync(
"preprocess/api.json",
JSON.stringify({ version: pkg.version, components }, null, 2)
);

View file

@ -1,8 +1,8 @@
const fs = require("fs");
const sass = require("sass");
const autoprefixer = require("autoprefixer");
const postcss = require("postcss");
const path = require("path");
import fs from "fs";
import sass from "sass";
import autoprefixer from "autoprefixer";
import postcss from "postcss";
import path from "path";
(async () => {
const scss = fs
@ -10,7 +10,7 @@ const path = require("path");
.filter((file) => file.endsWith(".scss"))
.map((file) => path.parse(file));
for (const { name, base } of scss) {
for await (const { name, base } of scss) {
const file = `css/${base}`;
const outFile = `css/${name}.css`;