-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
4,106 additions
and
1,676 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
{ | ||
// See http://go.microsoft.com/fwlink/?LinkId=827846 | ||
// for the documentation about the extensions.json format | ||
"recommendations": [ | ||
"dbaeumer.vscode-eslint" | ||
] | ||
// See http://go.microsoft.com/fwlink/?LinkId=827846 | ||
// for the documentation about the extensions.json format | ||
"recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,42 @@ | ||
// Place your settings in this file to overwrite default and user settings. | ||
{ | ||
"files.exclude": { | ||
"out": false // set this to true to hide the "out" folder with the compiled JS files | ||
}, | ||
"search.exclude": { | ||
"out": true // set this to false to include "out" folder in search results | ||
}, | ||
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts | ||
"typescript.tsc.autoDetect": "off", | ||
"editor.formatOnSave": true | ||
} | ||
"files.exclude": { | ||
"out": false // set this to true to hide the "out" folder with the compiled JS files | ||
}, | ||
"search.exclude": { | ||
"out": true // set this to false to include "out" folder in search results | ||
}, | ||
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts | ||
"typescript.tsc.autoDetect": "off", | ||
"editor.formatOnSave": true, | ||
"editor.tabSize": 2, | ||
"files.encoding": "utf8", | ||
"files.eol": "\n", | ||
"files.trimTrailingWhitespace": true, | ||
"files.insertFinalNewline": true, | ||
"[javascript]": { | ||
"editor.formatOnSave": true, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"[typescript]": { | ||
"editor.formatOnSave": true, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"[typescriptreact]": { | ||
"editor.formatOnSave": true, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"[json]": { | ||
"editor.formatOnSave": true, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"[html]": { | ||
"editor.formatOnSave": true, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"[css]": { | ||
"editor.formatOnSave": true, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"prettier.prettierPath": "./node_modules/prettier" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
const esbuild = require("esbuild"); | ||
const fs = require("fs"); | ||
|
||
const production = process.argv.includes("--production"); | ||
const watch = process.argv.includes("--watch"); | ||
const metafile = process.argv.includes("--metafile"); | ||
|
||
/** | ||
* @type {import('esbuild').Plugin} | ||
*/ | ||
const esbuildProblemMatcherPlugin = { | ||
name: "esbuild-problem-matcher", | ||
|
||
setup(build) { | ||
build.onStart(() => { | ||
console.log(build); | ||
console.log( | ||
`[${watch ? "watch " : ""}${new Date().toISOString()}] build ${ | ||
build.initialOptions.entryPoints | ||
}` | ||
); | ||
}); | ||
build.onEnd((result) => { | ||
result.errors.forEach(({ text, location }) => { | ||
console.error(`✘ [ERROR] ${text}`); | ||
console.error( | ||
` ${location.file}:${location.line}:${location.column}:` | ||
); | ||
}); | ||
|
||
// Log output files | ||
if (result.metafile) { | ||
Object.keys(result.metafile.outputs).forEach((output) => { | ||
console.log(`built: ${output}`); | ||
}); | ||
} | ||
}); | ||
}, | ||
}; | ||
|
||
const metafilePlugin = { | ||
name: "metafile", | ||
setup(build) { | ||
// const outfile = build.initialOptions.outfile; | ||
// const entryPoints = build.initialOptions.entryPoints; | ||
|
||
build.onEnd((result) => { | ||
if (result.metafile) { | ||
// For each output in the metafile | ||
Object.entries(result.metafile.outputs).forEach( | ||
([outputPath, output]) => { | ||
// Get the entry point for this output | ||
const entryPoint = output.entryPoint; | ||
if (entryPoint) { | ||
// Extract filename without extension | ||
const bundleName = entryPoint | ||
.replace(/^.*[\\/]/, "") | ||
.replace(/\.[^/.]+$/, ""); | ||
console.log(`meta.${bundleName}.json`); | ||
|
||
fs.writeFileSync( | ||
`${bundleName}.esbuild-meta.json`, | ||
JSON.stringify(result.metafile) | ||
); | ||
} | ||
} | ||
); | ||
} | ||
}); | ||
}, | ||
}; | ||
|
||
async function main() { | ||
const buildmap = { | ||
extension: esbuild.context({ | ||
entryPoints: ["src/extension.ts", "src/test/runTest.ts"], | ||
bundle: true, | ||
outdir: "out/", | ||
format: "cjs", | ||
minify: production, | ||
sourcemap: !production, | ||
sourcesContent: false, | ||
platform: "node", | ||
external: ["vscode"], | ||
logLevel: "silent", | ||
metafile: metafile, | ||
plugins: [metafilePlugin, esbuildProblemMatcherPlugin], | ||
}), | ||
}; | ||
|
||
Object.values(buildmap).forEach((build) => | ||
build | ||
.then(async (context) => { | ||
if (watch) { | ||
await context.watch(); | ||
} else { | ||
await context.rebuild(); | ||
await context.dispose(); | ||
} | ||
}) | ||
.catch(() => process.exit(1)) | ||
); | ||
} | ||
|
||
main().catch((e) => { | ||
console.error(e); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import eslint from "@eslint/js"; | ||
import tsParser from "@typescript-eslint/parser"; | ||
import globals from "globals"; | ||
import tseslint from "typescript-eslint"; | ||
|
||
const commonRules = { | ||
"@typescript-eslint/naming-convention": "warn", | ||
curly: ["warn", "multi-line"], | ||
eqeqeq: "warn", | ||
"no-throw-literal": "warn", | ||
semi: "warn", | ||
"@typescript-eslint/no-unused-vars": "off", | ||
"@typescript-eslint/consistent-type-imports": "warn", | ||
"@typescript-eslint/no-floating-promises": "error", | ||
}; | ||
|
||
const commonTsConfig = { | ||
parser: tsParser, | ||
ecmaVersion: 2022, | ||
sourceType: "module", | ||
parserOptions: { | ||
ecmaVersion: 2022, | ||
sourceType: "module", | ||
project: "./tsconfig.json", | ||
ecmaFeatures: { | ||
jsx: true, | ||
}, | ||
}, | ||
}; | ||
|
||
export default tseslint.config( | ||
eslint.configs.recommended, | ||
...tseslint.configs.recommended, | ||
{ | ||
ignores: ["out", "**/*.d.ts"], | ||
}, | ||
{ | ||
// Build scripts config - these are run by nodejs, and use commonjs syntax. | ||
files: ["esbuild.js", "**/tailwind.config.js"], | ||
languageOptions: { | ||
globals: globals.node, | ||
}, | ||
rules: { | ||
"@typescript-eslint/no-require-imports": "off", | ||
}, | ||
}, | ||
{ | ||
// Node.js TypeScript files (src/) | ||
files: ["src/**/*.ts"], | ||
languageOptions: { | ||
...commonTsConfig, | ||
globals: globals.node, | ||
}, | ||
rules: commonRules, | ||
} | ||
); |
Oops, something went wrong.