Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSC Extension JSON schema #9386

Merged
merged 2 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions packages/utils/parcelforvscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,25 @@
"onStartupFinished"
],
"contributes": {
"jsonValidation": [
{
"fileMatch": ".parcelrc",
"url": "./schemas/parcelrc.schema.json"
},
{
"fileMatch": "package.json",
"url": "./schemas/package-targets.schema.json"
}
],
"languages": [
{
"id": "jsonc",
"filenames": [
".parcelrc",
".parcelrc*"
]
}
],
"views": {
"explorer": [
{
Expand Down
167 changes: 167 additions & 0 deletions packages/utils/parcelforvscode/schemas/package-targets.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
{
"title": "JSON schema for .parcelrc files",
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"$defs": {
"engines": {
"type": "object",
"properties": {
"browsers": {
"oneOf": [
{
"type": "array",
"items": {
"type": "string"
}
},
{
"type": "string"
}
]
}
},
"additionalProperties": {
"type": "string"
}
},
"target": {
"type": "object",
"properties": {
"context": {
"description": "The context property defines what type of environment to build for. This tells Parcel what environment-specific APIs are available, e.g. the DOM, Node filesystem APIs.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of this JSON duplicates what https://github.com/parcel-bundler/parcel/blob/9d6da2c/packages/core/core/src/TargetDescriptor.schema.js does, but descriptions seem novel.

I think if you add descriptions into TargetDescriptor.schema.js, you can just generate this file. (my script for generating json from TargetDescriptor.schema.js https://github.com/lukaw3d/parcel-bundler-json-schemas/blob/main/main.js)

"type": "string",
"enum": [
"node",
"browser",
"web-worker",
"electron-main",
"electron-renderer",
"service-worker"
]
},
"includeNodeModules": {
"description": "Determines whether to bundle node_modules or treat them as external. The default is true for browser targets, and false for library targets.",
"oneOf": [
{
"type": "boolean"
},
{
"type": "array",
"items": {
"type": "string",
"description": "a wildcard or filepath"
}
},
{
"type": "object",
"properties": {},
"additionalProperties": {
"type": "boolean"
}
}
]
},
"outputFormat": {
"description": "Defines what type of module to output.",
"type": "string",
"enum": ["global", "esmodule", "commonjs"]
},
"distDir": {
"description": "Sets the location where compiled bundles in this target will be written",
"type": "string"
},
"publicUrl": {
"description": "Sets the base URL at which this bundle will be loaded at runtime",
"type": "string"
},
"isLibrary": {
"description": "When set to true, the target is treated as a library that would be published to npm and consumed by another tool rather than used directly in a browser or other target environment.",
"type": "boolean"
},
"source": {
"description": "Overrides the top-level `source` field in package.json for a target. This allows for each target to have different entries.",
"oneOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
},
"sourceMap": {
"description": "Enables or disables source maps, and sets source map options.",
"oneOf": [
{
"type": "boolean"
},
{
"type": "object",
"properties": {
"inlineSources": {
"type": "boolean"
},
"sourceRoot": {
"type": "string"
},
"inline": {
"type": "boolean"
}
},
"additionalProperties": false
}
]
},
"engines": {
"description": "Overrides the engines defined in the top-level `package.json#engines` and `browserslist` fields for this target.",
"$ref": "#/$defs/engines"
},
"optimize": {
"description": "Enables or disables optimization (e.g. minification). Exact behavior is determined by plugins.",
"type": "boolean"
},
"scopeHoist": {
"description": "Enables or disables scope hoisting.",
"type": "boolean"
}
},
"additionalProperties": false
},
"commonTarget": {
"oneOf": [
{
"$ref": "#/$defs/target"
},
{
"enum": [false]
}
]
}
},
"properties": {
"targets": {
"type": "object",
"description": "Parcel can compile your source code in multiple different ways (targets) simultaneously.",
"properties": {
"main": {
"$ref": "#/$defs/commonTarget"
},
"module": {
"$ref": "#/$defs/commonTarget"
},
"browser": {
"$ref": "#/$defs/commonTarget"
},
"types": {
"$ref": "#/$defs/commonTarget"
}
},
"additionalProperties": {
"$ref": "#/$defs/target"
}
}
}
}
94 changes: 94 additions & 0 deletions packages/utils/parcelforvscode/schemas/parcelrc.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"title": "JSON schema for .parcelrc files",
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"allowTrailingCommas": true,
"$defs": {
"plugin": {
"type": "string"
},
"plugins": {
"defaultSnippets": [
{
"body": ["$1", "..."]
}
],
"type": "array",
"uniqueItems": true,
"items": {
"$ref": "#/$defs/plugin"
}
},
"pluginGlobMap": {
"type": "object",
"properties": {},
"additionalProperties": {
"$ref": "#/$defs/plugin"
}
},
"pluginsGlobMap": {
"type": "object",
"properties": {},
"additionalProperties": {
"$ref": "#/$defs/plugins"
}
}
},
"properties": {
"extends": {
"oneOf": [
{
"$ref": "#/$defs/plugin"
},
{
"$ref": "#/$defs/plugins"
}
],
"default": "@parcel/extends-default"
},
"bundler": {
"description": "Transform the entire asset graph by grouping the assets into the output bundles.",
"$ref": "#/$defs/plugin"
},
"resolvers": {
"description": "Resolve a dependency to a file path or virtual module.",
"$ref": "#/$defs/plugins"
},
"transformers": {
"description": "Compile individual source files and extract dependencies.",
"$ref": "#/$defs/pluginsGlobMap"
},
"validators": {
"description": "Validates individual assets and can throw errors or log warnings with diagnostics to validate the input.",
"$ref": "#/$defs/pluginsGlobMap"
},
"namers": {
"description": "Determine the name of an output bundle.",
"$ref": "#/$defs/plugins"
},
"packagers": {
"description": "Combine multiple assets together into a single output bundle.",
"$ref": "#/$defs/pluginGlobMap"
},
"optimizers": {
"description": "Minify, optimize, and transform output bundles.",
"$ref": "#/$defs/pluginsGlobMap"
},
"compressors": {
"description": "Compress and encode output bundles in multiple formats.",
"$ref": "#/$defs/pluginsGlobMap"
},
"reporters": {
"description": "Receive events on build progress and completion.",
"$ref": "#/$defs/plugins"
},
"runtimes": {
"description": "Return additional assets to be inserted into a bundle.",
"$ref": "#/$defs/plugins"
}
},
"additionalProperties": false,
"default": {
"extends": "@parcel/config-default"
}
}
Loading