module-replacements 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 James Garbutt
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
@@ -0,0 +1,59 @@
1
+ # module-replacements
2
+
3
+ This package provides a set of manifests which each define a mapping of
4
+ JS modules to their suggested replacements.
5
+
6
+ ## Usage
7
+
8
+ You can install this package via NPM:
9
+
10
+ ```sh
11
+ npm i -S module-replacements
12
+ ```
13
+
14
+ You can then import the manifest of your choice:
15
+
16
+ ```ts
17
+ import {NativeReplacements} from 'module-replacements';
18
+ ```
19
+
20
+ ## Manifests
21
+
22
+ We provide three manifests:
23
+
24
+ - All (includes every manifest)
25
+ - Native replacements (modules which can be replaced by native equivalents)
26
+ - Optimisation replacements (modules which can be replaced by leaner or
27
+ closer-to-the-platform equivalents)
28
+
29
+ ### Native replacements
30
+
31
+ These are modules which can now be replaced by native functionality.
32
+
33
+ For example, pseudo-polyfills which provide functionality of widely available
34
+ platform features can be replaced by their platform equivalents.
35
+
36
+ Similarly, features which did not exist at the time but have now existed in
37
+ the platform for many years, so no longer need a dependency.
38
+
39
+ ### Optimisation replacements
40
+
41
+ These are modules which have more optimal replacements.
42
+
43
+ For example, some modules have arguably unnecessarily deep dependencies trees,
44
+ or rely on functionality themselves which fit into the "Native replacements"
45
+ category. These should likely be replaced by leaner alternatives.
46
+
47
+ Another example - modules which are too granularly modularised, leading to
48
+ unnecessarily large amounts of small dependencies (aka "micro dependencies").
49
+
50
+ Due to this being a one-to-many mapping (there are often many possible
51
+ replacements), this list can contain multiple replacements per module.
52
+
53
+ # Contributing
54
+
55
+ If you would like to add a replacement mapping to one of the manifests, please
56
+ open an issue where this can be discussed.
57
+
58
+ Keep in mind, very newly available native features are unlikely to join the
59
+ list since they are not widely available yet.
@@ -0,0 +1,18 @@
1
+ export interface ManifestModule {
2
+ id: string;
3
+ replacements: string[];
4
+ }
5
+ export interface ManifestReplacement {
6
+ id: string;
7
+ native?: boolean;
8
+ example: string;
9
+ url: string;
10
+ }
11
+ export interface Manifest {
12
+ modules: ManifestModule[];
13
+ replacements: ManifestReplacement[];
14
+ }
15
+ declare const nativeReplacements: Manifest;
16
+ declare const optimisationReplacements: Manifest;
17
+ export { nativeReplacements, optimisationReplacements };
18
+ export declare const all: Manifest;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.all = exports.optimisationReplacements = exports.nativeReplacements = void 0;
7
+ const native_json_1 = __importDefault(require("../manifests/native.json"));
8
+ const optimisation_json_1 = __importDefault(require("../manifests/optimisation.json"));
9
+ const nativeReplacements = native_json_1.default;
10
+ exports.nativeReplacements = nativeReplacements;
11
+ const optimisationReplacements = optimisation_json_1.default;
12
+ exports.optimisationReplacements = optimisationReplacements;
13
+ exports.all = {
14
+ modules: [...native_json_1.default.modules, ...optimisation_json_1.default.modules],
15
+ replacements: [...native_json_1.default.replacements, ...optimisation_json_1.default.replacements]
16
+ };
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,18 @@
1
+ export interface ManifestModule {
2
+ id: string;
3
+ replacements: string[];
4
+ }
5
+ export interface ManifestReplacement {
6
+ id: string;
7
+ native?: boolean;
8
+ example: string;
9
+ url: string;
10
+ }
11
+ export interface Manifest {
12
+ modules: ManifestModule[];
13
+ replacements: ManifestReplacement[];
14
+ }
15
+ declare const nativeReplacements: Manifest;
16
+ declare const optimisationReplacements: Manifest;
17
+ export { nativeReplacements, optimisationReplacements };
18
+ export declare const all: Manifest;
@@ -0,0 +1,9 @@
1
+ import native from '../manifests/native.json';
2
+ import optimisation from '../manifests/optimisation.json';
3
+ const nativeReplacements = native;
4
+ const optimisationReplacements = optimisation;
5
+ export { nativeReplacements, optimisationReplacements };
6
+ export const all = {
7
+ modules: [...native.modules, ...optimisation.modules],
8
+ replacements: [...native.replacements, ...optimisation.replacements]
9
+ };
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "module-replacements",
3
+ "description": "This package provides a set of manifests which each define a mapping of JS modules to their suggested replacements.",
4
+ "version": "1.0.0",
5
+ "main": "./dist/commonjs/main.js",
6
+ "scripts": {
7
+ "clean": "rimraf dist main.js",
8
+ "prepare": "tshy",
9
+ "format": "prettier --write \"./src/**/*.ts\" \"./manifests/**/*.json\"",
10
+ "build:types": "tsc --noEmit",
11
+ "build:bundle": "esbuild src/main.ts --format=esm --outfile=main.js --bundle",
12
+ "build": "npm run clean && npm run build:bundle && npm run build:types"
13
+ },
14
+ "tshy": {
15
+ "exports": {
16
+ ".": "./src/main.ts"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "!dist/node_modules"
22
+ ],
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/es-tooling/module-replacements.git"
26
+ },
27
+ "author": "James Garbutt (https://github.com/43081j)",
28
+ "license": "MIT",
29
+ "bugs": {
30
+ "url": "https://github.com/es-tooling/module-replacements/issues"
31
+ },
32
+ "homepage": "https://github.com/es-tooling/module-replacements#readme",
33
+ "devDependencies": {
34
+ "esbuild": "^0.20.0",
35
+ "prettier": "^3.2.4",
36
+ "rimraf": "^5.0.5",
37
+ "tshy": "^1.11.0",
38
+ "typescript": "^5.3.3"
39
+ },
40
+ "exports": {
41
+ ".": {
42
+ "import": {
43
+ "types": "./dist/esm/main.d.ts",
44
+ "default": "./dist/esm/main.js"
45
+ },
46
+ "require": {
47
+ "types": "./dist/commonjs/main.d.ts",
48
+ "default": "./dist/commonjs/main.js"
49
+ }
50
+ }
51
+ },
52
+ "types": "./dist/commonjs/main.d.ts",
53
+ "type": "module"
54
+ }