diff --git a/.gitignore b/.gitignore index 59cc215..194fcd5 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,141 @@ #### -- TEMPLATES BEGIN -- #### +### Node + +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp +.cache + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + #### -- TEMPLATES END -- #### # Allow to presever folder structure in excluded folers, should be the last rule !**/.gitkeep +dist diff --git a/.justfile b/.justfile index a442fcc..4ebebda 100644 --- a/.justfile +++ b/.justfile @@ -2,4 +2,4 @@ mod repo ".devfiles/justfile" dev: - @echo "Edit the .justfile to setup the dev task!" + watchexec --restart --clear --watch ./src bun run ./src/cli.ts diff --git a/bun.lock b/bun.lock new file mode 100644 index 0000000..9e8afbb --- /dev/null +++ b/bun.lock @@ -0,0 +1,97 @@ +{ + "lockfileVersion": 1, + "workspaces": { + "": { + "name": "bun-static-plugin", + "dependencies": { + "sass": "^1.85.0", + "slug": "^10.0.0", + }, + "devDependencies": { + "@mini-strap/core": "^0.1.2", + "@types/bun": "latest", + "@types/slug": "^5.0.9", + }, + "peerDependencies": { + "typescript": "^5.0.0", + }, + }, + }, + "packages": { + "@mini-strap/core": ["@mini-strap/core@0.1.2", "https://git.alecodes.page/api/packages/alecodes/npm/%40mini-strap%2Fcore/-/0.1.2/core-0.1.2.tgz", { "peerDependencies": { "typescript": "^5.0.0" }, "bin": { "@mini-strap/core": "build.ts" } }, "sha512-bt9su5jpslUMYmoNLz7s8P6RlN7Knriy8BtHBfVnpEizOh3DroStRr+yDCSLfhyByKXo6sa9ZNytc25ianEtbA=="], + + "@parcel/watcher": ["@parcel/watcher@2.5.1", "", { "dependencies": { "detect-libc": "^1.0.3", "is-glob": "^4.0.3", "micromatch": "^4.0.5", "node-addon-api": "^7.0.0" }, "optionalDependencies": { "@parcel/watcher-android-arm64": "2.5.1", "@parcel/watcher-darwin-arm64": "2.5.1", "@parcel/watcher-darwin-x64": "2.5.1", "@parcel/watcher-freebsd-x64": "2.5.1", "@parcel/watcher-linux-arm-glibc": "2.5.1", "@parcel/watcher-linux-arm-musl": "2.5.1", "@parcel/watcher-linux-arm64-glibc": "2.5.1", "@parcel/watcher-linux-arm64-musl": "2.5.1", "@parcel/watcher-linux-x64-glibc": "2.5.1", "@parcel/watcher-linux-x64-musl": "2.5.1", "@parcel/watcher-win32-arm64": "2.5.1", "@parcel/watcher-win32-ia32": "2.5.1", "@parcel/watcher-win32-x64": "2.5.1" } }, "sha512-dfUnCxiN9H4ap84DvD2ubjw+3vUNpstxa0TneY/Paat8a3R4uQZDLSvWjmznAY/DoahqTHl9V46HF/Zs3F29pg=="], + + "@parcel/watcher-android-arm64": ["@parcel/watcher-android-arm64@2.5.1", "", { "os": "android", "cpu": "arm64" }, "sha512-KF8+j9nNbUN8vzOFDpRMsaKBHZ/mcjEjMToVMJOhTozkDonQFFrRcfdLWn6yWKCmJKmdVxSgHiYvTCef4/qcBA=="], + + "@parcel/watcher-darwin-arm64": ["@parcel/watcher-darwin-arm64@2.5.1", "", { "os": "darwin", "cpu": "arm64" }, "sha512-eAzPv5osDmZyBhou8PoF4i6RQXAfeKL9tjb3QzYuccXFMQU0ruIc/POh30ePnaOyD1UXdlKguHBmsTs53tVoPw=="], + + "@parcel/watcher-darwin-x64": ["@parcel/watcher-darwin-x64@2.5.1", "", { "os": "darwin", "cpu": "x64" }, "sha512-1ZXDthrnNmwv10A0/3AJNZ9JGlzrF82i3gNQcWOzd7nJ8aj+ILyW1MTxVk35Db0u91oD5Nlk9MBiujMlwmeXZg=="], + + "@parcel/watcher-freebsd-x64": ["@parcel/watcher-freebsd-x64@2.5.1", "", { "os": "freebsd", "cpu": "x64" }, "sha512-SI4eljM7Flp9yPuKi8W0ird8TI/JK6CSxju3NojVI6BjHsTyK7zxA9urjVjEKJ5MBYC+bLmMcbAWlZ+rFkLpJQ=="], + + "@parcel/watcher-linux-arm-glibc": ["@parcel/watcher-linux-arm-glibc@2.5.1", "", { "os": "linux", "cpu": "arm" }, "sha512-RCdZlEyTs8geyBkkcnPWvtXLY44BCeZKmGYRtSgtwwnHR4dxfHRG3gR99XdMEdQ7KeiDdasJwwvNSF5jKtDwdA=="], + + "@parcel/watcher-linux-arm-musl": ["@parcel/watcher-linux-arm-musl@2.5.1", "", { "os": "linux", "cpu": "arm" }, "sha512-6E+m/Mm1t1yhB8X412stiKFG3XykmgdIOqhjWj+VL8oHkKABfu/gjFj8DvLrYVHSBNC+/u5PeNrujiSQ1zwd1Q=="], + + "@parcel/watcher-linux-arm64-glibc": ["@parcel/watcher-linux-arm64-glibc@2.5.1", "", { "os": "linux", "cpu": "arm64" }, "sha512-LrGp+f02yU3BN9A+DGuY3v3bmnFUggAITBGriZHUREfNEzZh/GO06FF5u2kx8x+GBEUYfyTGamol4j3m9ANe8w=="], + + "@parcel/watcher-linux-arm64-musl": ["@parcel/watcher-linux-arm64-musl@2.5.1", "", { "os": "linux", "cpu": "arm64" }, "sha512-cFOjABi92pMYRXS7AcQv9/M1YuKRw8SZniCDw0ssQb/noPkRzA+HBDkwmyOJYp5wXcsTrhxO0zq1U11cK9jsFg=="], + + "@parcel/watcher-linux-x64-glibc": ["@parcel/watcher-linux-x64-glibc@2.5.1", "", { "os": "linux", "cpu": "x64" }, "sha512-GcESn8NZySmfwlTsIur+49yDqSny2IhPeZfXunQi48DMugKeZ7uy1FX83pO0X22sHntJ4Ub+9k34XQCX+oHt2A=="], + + "@parcel/watcher-linux-x64-musl": ["@parcel/watcher-linux-x64-musl@2.5.1", "", { "os": "linux", "cpu": "x64" }, "sha512-n0E2EQbatQ3bXhcH2D1XIAANAcTZkQICBPVaxMeaCVBtOpBZpWJuf7LwyWPSBDITb7In8mqQgJ7gH8CILCURXg=="], + + "@parcel/watcher-win32-arm64": ["@parcel/watcher-win32-arm64@2.5.1", "", { "os": "win32", "cpu": "arm64" }, "sha512-RFzklRvmc3PkjKjry3hLF9wD7ppR4AKcWNzH7kXR7GUe0Igb3Nz8fyPwtZCSquGrhU5HhUNDr/mKBqj7tqA2Vw=="], + + "@parcel/watcher-win32-ia32": ["@parcel/watcher-win32-ia32@2.5.1", "", { "os": "win32", "cpu": "ia32" }, "sha512-c2KkcVN+NJmuA7CGlaGD1qJh1cLfDnQsHjE89E60vUEMlqduHGCdCLJCID5geFVM0dOtA3ZiIO8BoEQmzQVfpQ=="], + + "@parcel/watcher-win32-x64": ["@parcel/watcher-win32-x64@2.5.1", "", { "os": "win32", "cpu": "x64" }, "sha512-9lHBdJITeNR++EvSQVUcaZoWupyHfXe1jZvGZ06O/5MflPcuPLtEphScIBL+AiCWBO46tDSHzWyD0uDmmZqsgA=="], + + "@types/bun": ["@types/bun@1.2.2", "", { "dependencies": { "bun-types": "1.2.2" } }, "sha512-tr74gdku+AEDN5ergNiBnplr7hpDp3V1h7fqI2GcR/rsUaM39jpSeKH0TFibRvU0KwniRx5POgaYnaXbk0hU+w=="], + + "@types/node": ["@types/node@22.13.4", "", { "dependencies": { "undici-types": "~6.20.0" } }, "sha512-ywP2X0DYtX3y08eFVx5fNIw7/uIv8hYUKgXoK8oayJlLnKcRfEYCxWMVE1XagUdVtCJlZT1AU4LXEABW+L1Peg=="], + + "@types/slug": ["@types/slug@5.0.9", "", {}, "sha512-6Yp8BSplP35Esa/wOG1wLNKiqXevpQTEF/RcL/NV6BBQaMmZh4YlDwCgrrFSoUE4xAGvnKd5c+lkQJmPrBAzfQ=="], + + "@types/ws": ["@types/ws@8.5.14", "", { "dependencies": { "@types/node": "*" } }, "sha512-bd/YFLW+URhBzMXurx7lWByOu+xzU9+kb3RboOteXYDfW+tr+JZa99OyNmPINEGB/ahzKrEuc8rcv4gnpJmxTw=="], + + "braces": ["braces@3.0.3", "", { "dependencies": { "fill-range": "^7.1.1" } }, "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA=="], + + "bun-types": ["bun-types@1.2.2", "", { "dependencies": { "@types/node": "*", "@types/ws": "~8.5.10" } }, "sha512-RCbMH5elr9gjgDGDhkTTugA21XtJAy/9jkKe/G3WR2q17VPGhcquf9Sir6uay9iW+7P/BV0CAHA1XlHXMAVKHg=="], + + "chokidar": ["chokidar@4.0.3", "", { "dependencies": { "readdirp": "^4.0.1" } }, "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA=="], + + "detect-libc": ["detect-libc@1.0.3", "", { "bin": { "detect-libc": "./bin/detect-libc.js" } }, "sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg=="], + + "fill-range": ["fill-range@7.1.1", "", { "dependencies": { "to-regex-range": "^5.0.1" } }, "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg=="], + + "immutable": ["immutable@5.0.3", "", {}, "sha512-P8IdPQHq3lA1xVeBRi5VPqUm5HDgKnx0Ru51wZz5mjxHr5n3RWhjIpOFU7ybkUxfB+5IToy+OLaHYDBIWsv+uw=="], + + "is-extglob": ["is-extglob@2.1.1", "", {}, "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ=="], + + "is-glob": ["is-glob@4.0.3", "", { "dependencies": { "is-extglob": "^2.1.1" } }, "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg=="], + + "is-number": ["is-number@7.0.0", "", {}, "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng=="], + + "micromatch": ["micromatch@4.0.8", "", { "dependencies": { "braces": "^3.0.3", "picomatch": "^2.3.1" } }, "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA=="], + + "node-addon-api": ["node-addon-api@7.1.1", "", {}, "sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ=="], + + "picomatch": ["picomatch@2.3.1", "", {}, "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="], + + "readdirp": ["readdirp@4.1.2", "", {}, "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg=="], + + "sass": ["sass@1.85.0", "", { "dependencies": { "chokidar": "^4.0.0", "immutable": "^5.0.2", "source-map-js": ">=0.6.2 <2.0.0" }, "optionalDependencies": { "@parcel/watcher": "^2.4.1" }, "bin": { "sass": "sass.js" } }, "sha512-3ToiC1xZ1Y8aU7+CkgCI/tqyuPXEmYGJXO7H4uqp0xkLXUqp88rQQ4j1HmP37xSJLbCJPaIiv+cT1y+grssrww=="], + + "slug": ["slug@10.0.0", "", { "bin": { "slug": "cli.js" } }, "sha512-M8s2PWOUeSCdD4S1NH5lCzXg2zFV1fozrtfr0FSKl65x+EF1rUowj+/vyFlnHgxPxWzT+DL0VXKfYc1DHJoymg=="], + + "source-map-js": ["source-map-js@1.2.1", "", {}, "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA=="], + + "to-regex-range": ["to-regex-range@5.0.1", "", { "dependencies": { "is-number": "^7.0.0" } }, "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ=="], + + "typescript": ["typescript@5.7.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw=="], + + "undici-types": ["undici-types@6.20.0", "", {}, "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg=="], + } +} diff --git a/bunfig.toml b/bunfig.toml new file mode 100644 index 0000000..63cb7c5 --- /dev/null +++ b/bunfig.toml @@ -0,0 +1,4 @@ +[install.scopes] + +"@alecodes" = { token = "$NPM_REGISTRY_TOKEN", url = "https://git.alecodes.page/api/packages/alecodes/npm/" } +"@mini-strap" = { token = "$NPM_REGISTRY_TOKEN", url = "https://git.alecodes.page/api/packages/alecodes/npm/" } diff --git a/package.json b/package.json new file mode 100644 index 0000000..1e37d81 --- /dev/null +++ b/package.json @@ -0,0 +1,18 @@ +{ + "name": "bun-static-plugin", + "module": "src/index.ts", + "bin": "src/cli.ts", + "type": "module", + "devDependencies": { + "@mini-strap/core": "^0.1.2", + "@types/bun": "latest", + "@types/slug": "^5.0.9" + }, + "peerDependencies": { + "typescript": "^5.0.0" + }, + "dependencies": { + "sass": "^1.85.0", + "slug": "^10.0.0" + } +} diff --git a/src/cli.ts b/src/cli.ts new file mode 100644 index 0000000..911646e --- /dev/null +++ b/src/cli.ts @@ -0,0 +1,25 @@ +import Plugin, { LogType } from "./index.ts"; +import { EntrypointType, type Config, type Entrypoint } from "./types.ts"; + +const config: Config = { + production: false, + outdir: "dist", + root: "testfiles", +}; + +const entrypoints: Entrypoint[] = [ + { + path: "./testfiles/style.css", + type: EntrypointType.Css, + }, + { + path: "./testfiles/index.ts", + type: EntrypointType.Js, + }, + { + path: "@mini-strap/core", + type: EntrypointType.Package, + }, +]; + +await Plugin.build(config, entrypoints); diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..627da1f --- /dev/null +++ b/src/index.ts @@ -0,0 +1,205 @@ +import type { BuildConfig, BunPlugin, PluginBuilder } from "bun"; +import type { FileImporter } from "sass"; +import { type Config, type Entrypoint, EntrypointType, LogType } from "./types"; + +import { basename, join, normalize } from "node:path"; +import { fileURLToPath } from "node:url"; + +import { rm } from "node:fs/promises"; +import slug from "slug"; + +// This is used to prevent creating folders with external packages names +slug.extend({ "/": "-" }); + +const nodeModuleImporter: FileImporter<"async"> = { + findFileUrl(url) { + if (url.startsWith("@")) { + return new URL(import.meta.resolve(url)); + } + + return null; + }, +}; + +const sassPlugin: BunPlugin = { + name: "Sass Loader", + async setup(build: PluginBuilder) { + const sass = await import("sass"); + + build.onLoad({ filter: /\.scss$/ }, async ({ path }) => { + const result = await sass.compileAsync(path, { + importers: [nodeModuleImporter], + }); + + return { + loader: "css", + contents: result.css, + }; + }); + }, +}; + +function log(logtype: LogType, msg: string) { + const reset = "\x1b[0m"; + let color = Bun.color("white", "ansi"); + + switch (logtype) { + case LogType.Success: + color = Bun.color("green", "ansi"); + break; + case LogType.Error: + color = Bun.color("#f24444", "ansi"); + break; + + default: + break; + } + + if (!color) { + color = reset; + } + + console.log(color + msg + reset); +} + +// Packages needs to exist in the package.json file for this to work +function resolvePackage(pkg: string): Entrypoint { + const path = normalize(fileURLToPath(import.meta.resolve(pkg))); + const file = Bun.file(import.meta.resolve(pkg)); + const mimetype = file.type.split(";").at(0); + + let type: EntrypointType; + + switch (mimetype) { + case "text/x-scss": + type = EntrypointType.Sass; + break; + case "text/javascript": + type = EntrypointType.Js; + break; + default: + throw new Error(`No loader found for type ${mimetype} at path ${path}`); + } + + return { + path, + type, + }; +} + +export default { + log, + + build: async (config: Config, entrypoints: Entrypoint[]) => { + // Resolve external packages + + const external_cache: string[] = []; + const resolved_entrypoints = entrypoints.map((item) => { + if (item.type !== EntrypointType.Package) { + return item; + } + + external_cache.push(item.path); + return resolvePackage(item.path); + }); + + const baseConfig = { + minify: config.production, + outdir: `${config.outdir}/js`, + packages: "external", + root: config.root, + splitting: config.production, + }; + + // Apply build config per type + const loaders = { + assetLoader: { + entrypoints: resolved_entrypoints + .filter((entry) => entry.type === EntrypointType.Asset) + .map((entry) => entry.path), + outdir: `${config.outdir}/asset`, + }, + stylesLoader: { + ...baseConfig, + entrypoints: resolved_entrypoints + .filter((entry) => + [EntrypointType.Css, EntrypointType.Sass].includes(entry.type), + ) + .map((entry) => entry.path), + outdir: `${config.outdir}/css`, + plugins: [sassPlugin], + }, + jsLoader: { + ...baseConfig, + entrypoints: resolved_entrypoints + .filter((entry) => entry.type === EntrypointType.Js) + .map((entry) => entry.path), + target: "browser", + }, + }; + + // Transform into a list to later use Promise.all + const assets = Object.values(loaders).filter( + (item) => item.entrypoints.length !== 0, + ); + + log(LogType.Info, "Building assets..."); + + const out = await Promise.all( + assets.map(async (item) => { + const result = await Bun.build(item as BuildConfig); + + if (!result.success) { + throw new AggregateError(result.logs, "Build failed"); + } + + // Normalize external packages folder structure + for (const out of result.outputs) { + if (!out.path.includes("node_modules")) { + continue; + } + + let package_name = external_cache.find((pkg) => + out.path.includes(pkg), + ); + + if (!package_name) { + throw new Error( + `Could not normilize path for external package: ${out.path}`, + ); + } + + package_name = slug(package_name); + + if (!package_name) { + throw new Error( + `Could not normilize path for external package: ${out.path}`, + ); + } + + const new_path = join( + config.outdir, + "pkgs", + package_name, + basename(out.path), + ); + + await Bun.write(new_path, out); + } + + return result; + }), + ); + + if (out.some((item) => !item.success)) { + throw new Error(`Some entrypoint failed to build: ${out}`); + } + + await rm(join(config.outdir, "node_modules"), { + recursive: true, + force: true, + }); + + log(LogType.Success, "Complete!"); + }, +}; diff --git a/src/types.ts b/src/types.ts new file mode 100644 index 0000000..24e4e0d --- /dev/null +++ b/src/types.ts @@ -0,0 +1,26 @@ +export enum LogType { + Info = 1, + Success = 2, + Error = 3, +} + +export interface Config { + production: boolean; + outdir: string; + root?: string; +} + +// Try to match mime types +export enum EntrypointType { + Asset = "asset", + Js = "javascript", + Css = "css", + Sass = "scss", + Package = "pkg", +} + +export interface Entrypoint { + path: string; + type: EntrypointType; + outdir?: string; +} diff --git a/testfiles/index.ts b/testfiles/index.ts new file mode 100644 index 0000000..019c0f4 --- /dev/null +++ b/testfiles/index.ts @@ -0,0 +1 @@ +console.log("Hello World!"); diff --git a/testfiles/style.css b/testfiles/style.css new file mode 100644 index 0000000..608582d --- /dev/null +++ b/testfiles/style.css @@ -0,0 +1,3 @@ +* { + background-color: red; +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..238655f --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + // Enable latest features + "lib": ["ESNext", "DOM"], + "target": "ESNext", + "module": "ESNext", + "moduleDetection": "force", + "jsx": "react-jsx", + "allowJs": true, + + // Bundler mode + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "noEmit": true, + + // Best practices + "strict": true, + "skipLibCheck": true, + "noFallthroughCasesInSwitch": true, + + // Some stricter flags (disabled by default) + "noUnusedLocals": false, + "noUnusedParameters": false, + "noPropertyAccessFromIndexSignature": false + } +}