@shgysk8zer0/js-utils 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/LICENSE +21 -0
- package/README.md +2 -0
- package/package.json +47 -0
- package/rollup.cjs +51 -0
- package/rollup.js +44 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
All notable changes to this project will be documented in this file.
|
|
3
|
+
|
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [v1.0.0] - 2023-06-08
|
|
10
|
+
|
|
11
|
+
Initial Release
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Chris Zuber
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@shgysk8zer0/js-utils",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A collection of npm packages, such as ESLint and Rollup",
|
|
5
|
+
"module": "./index.js",
|
|
6
|
+
"main": "./index.cjs",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=18.0.0"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
"./*": {
|
|
12
|
+
"import": "./*.js",
|
|
13
|
+
"require": "./*.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"private": false,
|
|
18
|
+
"scripts": {
|
|
19
|
+
"test": "npm run lint:js && npm run build",
|
|
20
|
+
"preversion": "npm test",
|
|
21
|
+
"prepare": "npm run build",
|
|
22
|
+
"lint:js": "eslint .",
|
|
23
|
+
"fix:js": "eslint. --fix",
|
|
24
|
+
"build": "npm run build:rollup",
|
|
25
|
+
"build:rollup": "rollup -c rollup.config.js",
|
|
26
|
+
"create:lock": "npm i --package-lock-only",
|
|
27
|
+
"version:bump": "npm run version:bump:patch",
|
|
28
|
+
"version:bump:patch": "npm version --no-git-tag-version patch",
|
|
29
|
+
"version:bump:minor": "npm version --no-git-tag-version minor",
|
|
30
|
+
"version:bump:major": "npm version --no-git-tag-version major"
|
|
31
|
+
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/shgysk8zer0/js-utils.git"
|
|
35
|
+
},
|
|
36
|
+
"author": "Chris Zuber <admin@kernvalley.us>",
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/shgysk8zer0/js-utils/issues"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/shgysk8zer0/js-utils#readme",
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@rollup/plugin-terser": "^0.4.3",
|
|
44
|
+
"eslint": "^8.42.0",
|
|
45
|
+
"rollup": "^3.24.0"
|
|
46
|
+
}
|
|
47
|
+
}
|
package/rollup.cjs
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var node_path = require('node:path');
|
|
4
|
+
var terser = require('@rollup/plugin-terser');
|
|
5
|
+
|
|
6
|
+
/* eslint-env node */
|
|
7
|
+
|
|
8
|
+
const FORMAT_EXTS = {
|
|
9
|
+
'es': ['.mjs', '.js'],
|
|
10
|
+
'esm': ['.mjs', '.js'],
|
|
11
|
+
'module': ['.mjs', '.js'],
|
|
12
|
+
'cjs': ['.cjs'],
|
|
13
|
+
'iife': ['.min.js'],
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
function getExtensionForFormat(format) {
|
|
17
|
+
return FORMAT_EXTS[format][0];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function warningHandler(warning) {
|
|
21
|
+
if (warning.code === 'MISSING_GLOBAL_NAME' || warning.code === 'UNRESOLVED_IMPORT') {
|
|
22
|
+
throw new Error(warning.message);
|
|
23
|
+
} else if (warning.code !== 'CIRCULAR_DEPENDENCY') {
|
|
24
|
+
console.warn(`(!) ${warning.message}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async function getConfig(input, {
|
|
29
|
+
format = 'iife',
|
|
30
|
+
sourcemap = true,
|
|
31
|
+
onwarn = warningHandler,
|
|
32
|
+
external = [],
|
|
33
|
+
plugins = [],
|
|
34
|
+
globals = {},
|
|
35
|
+
minify = true,
|
|
36
|
+
} = {}) {
|
|
37
|
+
const ext = node_path.extname(input);
|
|
38
|
+
const file = input.replace(ext, getExtensionForFormat(format));
|
|
39
|
+
|
|
40
|
+
if (minify) {
|
|
41
|
+
plugins.push(terser());
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const output = { file, format, sourcemap, globals };
|
|
45
|
+
|
|
46
|
+
return { input, plugins, external, onwarn, output };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
exports.getConfig = getConfig;
|
|
50
|
+
exports.getExtensionForFormat = getExtensionForFormat;
|
|
51
|
+
exports.warningHandler = warningHandler;
|
package/rollup.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/* eslint-env node */
|
|
2
|
+
import { extname } from 'node:path';
|
|
3
|
+
import terser from '@rollup/plugin-terser';
|
|
4
|
+
|
|
5
|
+
const FORMAT_EXTS = {
|
|
6
|
+
'es': ['.mjs', '.js'],
|
|
7
|
+
'esm': ['.mjs', '.js'],
|
|
8
|
+
'module': ['.mjs', '.js'],
|
|
9
|
+
'cjs': ['.cjs'],
|
|
10
|
+
'iife': ['.min.js'],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export function getExtensionForFormat(format) {
|
|
14
|
+
return FORMAT_EXTS[format][0];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function warningHandler(warning) {
|
|
18
|
+
if (warning.code === 'MISSING_GLOBAL_NAME' || warning.code === 'UNRESOLVED_IMPORT') {
|
|
19
|
+
throw new Error(warning.message);
|
|
20
|
+
} else if (warning.code !== 'CIRCULAR_DEPENDENCY') {
|
|
21
|
+
console.warn(`(!) ${warning.message}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function getConfig(input, {
|
|
26
|
+
format = 'iife',
|
|
27
|
+
sourcemap = true,
|
|
28
|
+
onwarn = warningHandler,
|
|
29
|
+
external = [],
|
|
30
|
+
plugins = [],
|
|
31
|
+
globals = {},
|
|
32
|
+
minify = true,
|
|
33
|
+
} = {}) {
|
|
34
|
+
const ext = extname(input);
|
|
35
|
+
const file = input.replace(ext, getExtensionForFormat(format));
|
|
36
|
+
|
|
37
|
+
if (minify) {
|
|
38
|
+
plugins.push(terser());
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const output = { file, format, sourcemap, globals };
|
|
42
|
+
|
|
43
|
+
return { input, plugins, external, onwarn, output };
|
|
44
|
+
}
|