Website Structure

This commit is contained in:
supalerk-ar66 2026-01-13 10:46:40 +07:00
parent 62812f2090
commit 71f0676a62
22365 changed files with 4265753 additions and 791 deletions

View file

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2019 RollupJS Plugin Contributors (https://github.com/rollup/plugins/graphs/contributors)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View file

@ -0,0 +1,110 @@
[npm]: https://img.shields.io/npm/v/@rollup/plugin-json
[npm-url]: https://www.npmjs.com/package/@rollup/plugin-json
[size]: https://packagephobia.now.sh/badge?p=@rollup/plugin-json
[size-url]: https://packagephobia.now.sh/result?p=@rollup/plugin-json
[![npm][npm]][npm-url]
[![size][size]][size-url]
[![libera manifesto](https://img.shields.io/badge/libera-manifesto-lightgrey.svg)](https://liberamanifesto.com)
# @rollup/plugin-json
🍣 A Rollup plugin which Converts .json files to ES6 modules.
## Requirements
This plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v14.0.0+) and Rollup v1.20.0+.
## Install
Using npm:
```console
npm install @rollup/plugin-json --save-dev
```
## Usage
Create a `rollup.config.js` [configuration file](https://www.rollupjs.org/guide/en/#configuration-files) and import the plugin:
```js
import json from '@rollup/plugin-json';
export default {
input: 'src/index.js',
output: {
dir: 'output',
format: 'cjs'
},
plugins: [json()]
};
```
Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api).
With an accompanying file `src/index.js`, the local `package.json` file would now be importable as seen below:
```js
// src/index.js
import { readFileSync } from 'fs';
const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8'));
console.log(`running version ${pkg.version}`);
```
## Options
### `compact`
Type: `Boolean`<br>
Default: `false`
If `true`, instructs the plugin to ignore `indent` and generates the smallest code.
### `exclude`
Type: `String` | `Array[...String]`<br>
Default: `null`
A [picomatch pattern](https://github.com/micromatch/picomatch), or array of patterns, which specifies the files in the build the plugin should _ignore_. By default no files are ignored.
### `include`
Type: `String` | `Array[...String]`<br>
Default: `null`
A [picomatch pattern](https://github.com/micromatch/picomatch), or array of patterns, which specifies the files in the build the plugin should operate on. By default all files are targeted.
### `includeArbitraryNames`
Type: `Boolean`<br>
Default: `false`
If `true` and `namedExports` is `true`, generates a named export for not a valid identifier properties of the JSON object by leveraging the ["Arbitrary Module Namespace Identifier Names" feature](https://github.com/tc39/ecma262/pull/2154).
### `indent`
Type: `String`<br>
Default: `'\t'`
Specifies the indentation for the generated default export.
### `namedExports`
Type: `Boolean`<br>
Default: `true`
If `true`, instructs the plugin to generate a named export for every property of the JSON object.
### `preferConst`
Type: `Boolean`<br>
Default: `false`
If `true`, instructs the plugin to declare properties as variables, using either `var` or `const`. This pertains to tree-shaking.
## Meta
[CONTRIBUTING](/.github/CONTRIBUTING.md)
[LICENSE (MIT)](/LICENSE)

View file

@ -0,0 +1,43 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var pluginutils = require('@rollup/pluginutils');
function json(options) {
if ( options === void 0 ) options = {};
var filter = pluginutils.createFilter(options.include, options.exclude);
var indent = 'indent' in options ? options.indent : '\t';
return {
name: 'json',
// eslint-disable-next-line no-shadow
transform: function transform(code, id) {
if (id.slice(-5) !== '.json' || !filter(id)) { return null; }
try {
var parsed = JSON.parse(code);
return {
code: pluginutils.dataToEsm(parsed, {
preferConst: options.preferConst,
compact: options.compact,
namedExports: options.namedExports,
includeArbitraryNames: options.includeArbitraryNames,
indent: indent
}),
map: { mappings: '' }
};
} catch (err) {
var message = 'Could not parse JSON file';
this.error({ message: message, id: id, cause: err });
return null;
}
}
};
}
exports.default = json;
module.exports = Object.assign(exports.default, exports);
//# sourceMappingURL=index.js.map

View file

@ -0,0 +1,38 @@
import { createFilter, dataToEsm } from '@rollup/pluginutils';
function json(options) {
if ( options === void 0 ) options = {};
var filter = createFilter(options.include, options.exclude);
var indent = 'indent' in options ? options.indent : '\t';
return {
name: 'json',
// eslint-disable-next-line no-shadow
transform: function transform(code, id) {
if (id.slice(-5) !== '.json' || !filter(id)) { return null; }
try {
var parsed = JSON.parse(code);
return {
code: dataToEsm(parsed, {
preferConst: options.preferConst,
compact: options.compact,
namedExports: options.namedExports,
includeArbitraryNames: options.includeArbitraryNames,
indent: indent
}),
map: { mappings: '' }
};
} catch (err) {
var message = 'Could not parse JSON file';
this.error({ message: message, id: id, cause: err });
return null;
}
}
};
}
export { json as default };
//# sourceMappingURL=index.js.map

View file

@ -0,0 +1 @@
{"type":"module"}

View file

@ -0,0 +1,81 @@
{
"name": "@rollup/plugin-json",
"version": "6.1.0",
"publishConfig": {
"access": "public"
},
"description": "Convert .json files to ES6 modules",
"license": "MIT",
"repository": {
"url": "rollup/plugins",
"directory": "packages/json"
},
"author": "rollup",
"homepage": "https://github.com/rollup/plugins/tree/master/packages/json#readme",
"bugs": "https://github.com/rollup/plugins/issues",
"main": "./dist/cjs/index.js",
"module": "./dist/es/index.js",
"exports": {
"types": "./types/index.d.ts",
"import": "./dist/es/index.js",
"default": "./dist/cjs/index.js"
},
"engines": {
"node": ">=14.0.0"
},
"files": [
"dist",
"!dist/**/*.map",
"types",
"README.md",
"LICENSE"
],
"keywords": [
"rollup",
"plugin",
"json",
"es2015",
"npm",
"modules"
],
"peerDependencies": {
"rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0"
},
"peerDependenciesMeta": {
"rollup": {
"optional": true
}
},
"dependencies": {
"@rollup/pluginutils": "^5.1.0"
},
"devDependencies": {
"@rollup/plugin-buble": "^1.0.0",
"@rollup/plugin-node-resolve": "^15.0.0",
"rollup": "^4.0.0-24",
"source-map-support": "^0.5.21"
},
"types": "./types/index.d.ts",
"ava": {
"workerThreads": false,
"files": [
"!**/fixtures/**",
"!**/helpers/**",
"!**/recipes/**",
"!**/types.ts"
]
},
"scripts": {
"build": "rollup -c",
"ci:coverage": "nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov",
"ci:lint": "pnpm build && pnpm lint",
"ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}",
"ci:test": "pnpm test -- --verbose && pnpm test:ts",
"prebuild": "del-cli dist",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm --workspace-root package:release $(pwd)",
"test": "ava",
"test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
}
}

View file

@ -0,0 +1,41 @@
import type { FilterPattern } from '@rollup/pluginutils';
import type { Plugin } from 'rollup';
export interface RollupJsonOptions {
/**
* All JSON files will be parsed by default,
* but you can also specifically include files
*/
include?: FilterPattern;
/**
* All JSON files will be parsed by default,
* but you can also specifically exclude files
*/
exclude?: FilterPattern;
/**
* For tree-shaking, properties will be declared as variables, using
* either `var` or `const`.
* @default false
*/
preferConst?: boolean;
/**
* Specify indentation for the generated default export
* @default '\t'
*/
indent?: string;
/**
* Ignores indent and generates the smallest code
* @default false
*/
compact?: boolean;
/**
* Generate a named export for every property of the JSON object
* @default true
*/
namedExports?: boolean;
}
/**
* Convert .json files to ES6 modules
*/
export default function json(options?: RollupJsonOptions): Plugin;