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,9 +1,11 @@
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";
const pkg = JSON.parse(
fs.readFileSync(new URL("../package.json", import.meta.url), "utf8")
);
function buildApi() {
const components = {};
glob.sync("src/**/*.svelte").forEach((file) => {
@ -15,6 +17,3 @@ function buildApi() {
"preprocess/api.json",
JSON.stringify({ version: pkg.version, components }, null, 2)
);
}
buildApi();

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`;