Skip to content

Commit

Permalink
Publish as ESM [publish]
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBarre committed May 14, 2023
1 parent f7bf2bc commit 3bfc201
Show file tree
Hide file tree
Showing 45 changed files with 540 additions and 730 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
if: ${{ contains(github.event.head_commit.message, '[publish]') }}
steps:
- uses: actions/checkout@v3
- uses: xhyrom/setup-bun@v0.1.8
- uses: oven-sh/setup-bun@v1
- run: bun i
- run: bun ci
- uses: ArnaudBarre/npm-publish@v1
Expand Down
4 changes: 2 additions & 2 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/jsonCatalog.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/prettier.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/watcherTasks.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 0.6.0

Publish as ESM

## 0.5.1

Fix TS imports in bundle
Expand Down
2 changes: 0 additions & 2 deletions bench/fixtures/windicss/index.html

This file was deleted.

2 changes: 0 additions & 2 deletions bench/fixtures/windicss/main.js

This file was deleted.

6 changes: 0 additions & 6 deletions bench/fixtures/windicss/vite.config.js

This file was deleted.

5 changes: 3 additions & 2 deletions bench/gen.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env tnode
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";

const map = (a: string[], b: string[], separator = "-") => {
const classes = [];
Expand Down Expand Up @@ -70,7 +71,7 @@ const getContent = () =>
`// @downwind-scan
document.getElementById('app').className = "${shuffle(classes).join(" ")}"`;

const sourceDir = join(__dirname, "source");
const sourceDir = join(dirname(fileURLToPath(import.meta.url)), "source");
if (!existsSync(sourceDir)) mkdirSync(sourceDir);
writeFileSync(
join(sourceDir, "gen.js"),
Expand Down
14 changes: 7 additions & 7 deletions bench/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"private": true,
"type": "module",
"scripts": {
"bench": "./gen.ts && cd fixtures && hyperfine --runs 5 'cd downwind && vite build' 'cd none && vite build' 'cd tailwindcss && vite build' 'cd unocss && vite build' 'cd windicss && vite build'"
"bench": "./gen.ts && cd fixtures && hyperfine --runs 5 'cd downwind && vite build' 'cd none && vite build' 'cd tailwindcss && vite build' 'cd unocss && vite build'"
},
"devDependencies": {
"autoprefixer": "^10.4.12",
"tailwindcss": "^3.1.8",
"unocss": "^0.45.26",
"vite": "^3.1.6",
"vite-plugin-windicss": "^1.8.8",
"windicss": "^3.5.6"
"autoprefixer": "^10.4.14",
"tailwindcss": "^3.3.2",
"unocss": "^0.51.12",
"vite": "^4.3.5",
"vite-plugin-windicss": "^1.9.0"
}
}
21 changes: 21 additions & 0 deletions bench/results/2023-05-14.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Benchmark 1: cd downwind && vite build
Time (mean ± σ): 470.8 ms ± 17.2 ms [User: 525.2 ms, System: 75.4 ms]
Range (min … max): 457.8 ms … 498.8 ms 5 runs

Benchmark 2: cd none && vite build
Time (mean ± σ): 344.2 ms ± 10.6 ms [User: 344.2 ms, System: 53.8 ms]
Range (min … max): 332.1 ms … 357.8 ms 5 runs

Benchmark 3: cd tailwindcss && vite build
Time (mean ± σ): 1.363 s ± 0.015 s [User: 2.460 s, System: 0.143 s]
Range (min … max): 1.345 s … 1.386 s 5 runs

Benchmark 4: cd unocss && vite build
Time (mean ± σ): 711.5 ms ± 9.7 ms [User: 947.3 ms, System: 101.4 ms]
Range (min … max): 698.9 ms … 721.5 ms 5 runs

Summary
'cd none && vite build' ran
1.37 ± 0.07 times faster than 'cd downwind && vite build'
2.07 ± 0.07 times faster than 'cd unocss && vite build'
3.96 ± 0.13 times faster than 'cd tailwindcss && vite build'
Binary file modified bun.lockb
Binary file not shown.
31 changes: 12 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "@arnaud-barre/downwind",
"description": "A PostCSS-less implementation of Tailwind based on Lightning CSS",
"version": "0.5.1",
"type": "module",
"version": "0.6.0",
"author": "Arnaud Barré (https://github.com/ArnaudBarre)",
"license": "MIT",
"scripts": {
Expand All @@ -11,34 +12,26 @@
"tsc": "tsc && tsc -p playground/vite",
"test": "tests/run-tests.ts --update-snapshots",
"test-ci": "tests/run-tests.ts",
"lint": "bun run lint-ci --fix --cache",
"lint-ci": "eslint ./ --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"prettier": "bun run prettier-ci --write",
"prettier-ci": "prettier --check '**/*.{js,ts,tsx,html,css,json,md,yml}'",
"prettier-ci": "prettier --cache --check '**/*.{cjs,ts,tsx,html,css,json,md,yml}'",
"ci": "bun run build && bun tsc && bun test-ci && bun lint-ci && bun prettier-ci"
},
"prettier": {
"trailingComma": "all",
"quoteProps": "consistent",
"importOrderBuiltinModulesToTop": true,
"importOrder": [
"<THIRD_PARTY_MODULES>",
"",
"^[./]"
]
"quoteProps": "consistent"
},
"dependencies": {
"@arnaud-barre/config-loader": "^0.5.3",
"@arnaud-barre/config-loader": "^0.6.1",
"lightningcss": "^1.20.0"
},
"devDependencies": {
"@arnaud-barre/eslint-config": "^2.0.2",
"@ianvs/prettier-plugin-sort-imports": "^3.7.2",
"@nabla/tnode": "^0.9.0",
"@types/node": "^18.16.3",
"eslint": "^8.39.0",
"prettier": "^2.8.8",
"@arnaud-barre/prettier-plugin-sort-imports": "^0.1.0",
"@arnaud-barre/eslint-config": "^2.0.3",
"@arnaud-barre/tnode": "^0.17.1",
"@types/node": "^16.18.30",
"eslint": "^8.40.0",
"prettier": "^3.0.0-alpha.11",
"typescript": "^5.0.4",
"vite": "^4.3.3"
"vite": "^4.3.5"
}
}
8 changes: 5 additions & 3 deletions playground/playground.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env tnode
import { writeFileSync, existsSync } from "node:fs";
import { existsSync, writeFileSync } from "node:fs";

import "./set-version.ts";
import { initDownwindWithConfig } from "../src/index.ts";
Expand Down Expand Up @@ -34,8 +34,10 @@ console.log = (...args: any[]) =>
logs.push(args.map((v) => (typeof v === "object" ? JSON.stringify(v) : v)));

const downwind = initDownwindWithConfig({
// eslint-disable-next-line @typescript-eslint/no-require-imports
config: require("./config.ts").config,
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
// @ts-ignore (file exist locally but not on CI)
// eslint-disable-next-line import/no-unresolved
config: (await import("./config.ts")).config,
});
downwind.scan("./input.ts");

Expand Down
Binary file modified playground/vite/bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion playground/vite/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
8 changes: 4 additions & 4 deletions playground/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.2.0",
"@types/react-dom": "^18.2.1",
"@vitejs/plugin-react-swc": "^3.3.0",
"@types/react": "^18.2.6",
"@types/react-dom": "^18.2.4",
"@vitejs/plugin-react-swc": "^3.3.1",
"typescript": "^5.0.4",
"vite": "^4.3.3"
"vite": "^4.3.5"
}
}
1 change: 0 additions & 1 deletion playground/vite/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useState } from "react";

import styles from "./app.module.css";

export const App = () => {
Expand Down
1 change: 0 additions & 1 deletion playground/vite/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import react from "@vitejs/plugin-react-swc";
import { defineConfig } from "vite";

import { downwind } from "../../dist/vite.js";

// eslint-disable-next-line import/no-default-export
Expand Down
Loading

0 comments on commit 3bfc201

Please sign in to comment.