-
-
Notifications
You must be signed in to change notification settings - Fork 261
Description
VSCode allows us to extend JSON Schemas. This great feature provides developers the ability to feed custom stores to different JSON files. The JSON Language Server can digest externally provided stores and in-turn gives one validations, hover descriptions and various intellisense capabilities.
I use tsup in a couple of projects and tend to favor the package.json
configuration option but doing so I sacrifice the native TS completions supplied through typing declarations. Anyway, I like intelliSense capabilities and wrote a basic store for tsup (below).
Something like this is not worth a PR as it an opt-in. I wanted to (at the very least) drop this here and maybe it will be of use to the project of users who seek such features.
Extending Schemas in VSCode
Within workspace settings you need to simply point to store file and inform vscode to contribute this extensions to package.json
files:
Workspace Settings
{
"json.schemas": [
{
"fileMatch": ["package.json"],
"url": "./path-to-store/tsup.json"
}
]
}
JSON Schema Store
Below is a Schema Store that can be used the will provide all the options tsup exposes for package.json
configuration usage (ie: function options are omitted).
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "tsup",
"version": 1.1,
"definitions": {
"options": {
"type": "object",
"markdownDescription": "Configuration options for [tsup](https://tsup.egoist.sh)",
"additionalProperties": false,
"properties": {
"entry": {
"markdownDescription": "Files that each serve as an input to the bundling algorithm.\n\n---\nReferences:\n- [Entry Points](https://esbuild.github.io/api/#entry-points) - esbuild\n - [Multiple Entrypoints](https://tsup.egoist.sh/#multiple-entrypoints) - tsup",
"oneOf": [
{
"type": "array",
"items": {
"type": "string"
}
},
{
"type": "object"
}
]
},
"treeshake": {
"type": "boolean"
},
"name": {
"type": "string",
"description": "Optional config name to show in CLI output"
},
"legacyOutput": {
"type": "boolean",
"description": "Output different formats to different folder instead of using different extension"
},
"target": {
"markdownDescription": "This sets the target environment for the generated code\n\n---\nReferences:\n- [Target](https://esbuild.github.io/api/#target) - esbuild",
"default": "node14",
"oneOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
},
"minify": {
"type": "boolean",
"description": "When enabled, the generated code will be minified instead of pretty-printed."
},
"minifyWhitespace": {
"type": "boolean"
},
"minifyIdentifiers": {
"type": "boolean"
},
"minifySyntax": {
"type": "boolean"
},
"keepNames": {
"type": "boolean"
},
"watch": {
"oneOf": [
{
"type": "boolean"
},
{
"type": "string",
"items": {
"type": "string"
}
},
{
"type": "array",
"items": {
"type": ["string", "boolean"]
}
}
]
},
"ignoreWatch": {
"oneOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
},
"onSuccess": {
"type": "string"
},
"jsxFactory": {
"type": "string"
},
"jsxFragment": {
"type": "string"
},
"outDir": {
"type": "string"
},
"format": {
"oneOf": [
{
"enum": ["cjs", "iife", "esm"],
"type": "string"
},
{
"type": "array",
"uniqueItems": true,
"items": {
"type": "string",
"enum": ["cjs", "iife", "esm"]
}
}
]
},
"globalName": {
"type": "string"
},
"env": {
"type": "object"
},
"define": {
"type": "object"
},
"dts": {
"oneOf": [
{
"type": "boolean"
},
{
"type": "string"
},
{
"type": "object",
"properties": {
"entry": {
"oneOf": [
{
"type": "string"
},
{
"type": "object"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
}
}
}
]
},
"sourcemap": {
"oneOf": [
{
"type": "boolean"
},
{
"enum": ["inline"]
}
]
},
"noExternal": {
"type": "string",
"description": "Always bundle modules matching given patterns"
},
"external": {
"description": "Don't bundle these modules",
"type": "array",
"items": {
"type": "string"
}
},
"replaceNodeEnv": {
"type": "boolean",
"markdownDescription": "Replace `process.env.NODE_ENV` with `production` or `development` `production` when the bundled is minified, `development` otherwise"
},
"splitting": {
"type": "boolean",
"default": true,
"markdownDescription": "You may want to disable code splitting sometimes: [`#255`](https://github.com/egoist/tsup/issues/255)"
},
"clean": {
"description": "Clean output directory before each buil",
"oneOf": [
{
"type": "boolean"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
},
"silent": {
"type": "boolean",
"description": "Suppress non-error logs (excluding \"onSuccess\" process output)"
},
"skipNodeModulesBundle": {
"type": "boolean",
"description": "Skip node_modules bundling"
},
"pure": {
"markdownDescription": "See:\n- [Pure](https://esbuild.github.io/api/#pure) - esbuild",
"oneOf": [
{
"type": "boolean"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
},
"bundle": {
"default": true,
"type": "boolean",
"description": "Disable bundling, default to true"
},
"inject": {
"markdownDescription": "This option allows you to automatically replace a global variable with an import from another file.\n\n---\nSee:\n- [Inject](https://esbuild.github.io/api/#inject) - esbuild",
"type": "array",
"items": {
"type": "string"
}
},
"metafile": {
"type": "boolean",
"markdownDescription": "Emit esbuild metafile.\n\n---\nSee:\n- [Metafile](https://esbuild.github.io/api/#metafile) - esbuild"
},
"footer": {
"type": "object",
"properties": {
"js": {
"type": "string"
},
"css": {
"type": "string"
}
}
},
"banner": {
"type": "object",
"properties": {
"js": {
"type": "string"
},
"css": {
"type": "string"
}
}
},
"platform": {
"description": "Target platform",
"type": "string",
"default": "node",
"enum": ["node", "browser"]
},
"config": {
"markdownDescription": "Disable config file with `false` or pass a custom config filename",
"type": ["boolean", "string"]
},
"tsconfig": {
"type": "string",
"description": " Use a custom tsconfig"
},
"injectStyle": {
"type": "boolean",
"default": false,
"description": "Inject CSS as style tags to document head"
},
"shims": {
"type": "boolean",
"default": false,
"description": "Inject cjs and esm shims if needed"
}
}
}
},
"type": "object",
"properties": {
"tsup": {
"$ref": "#/definitions/options"
}
}
}