module-replacements 1.0.0 → 2.0.0-beta.1

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/README.md CHANGED
@@ -1,9 +1,19 @@
1
1
  # module-replacements
2
2
 
3
- This package provides a set of manifests which each define a mapping of
4
- JS modules to their suggested replacements.
3
+ This project provides two things:
5
4
 
6
- ## Usage
5
+ - A JS package containing manifests of suggested module replacements
6
+ - Documentation for replacements which are not entirely replaced by native
7
+ functionality
8
+
9
+ ## Replacements documentation
10
+
11
+ You can read more about module replacements and browse the list
12
+ [by clicking here](./docs/modules/README.md).
13
+
14
+ ## `module-replacements` package
15
+
16
+ ### Usage
7
17
 
8
18
  You can install this package via NPM:
9
19
 
@@ -17,16 +27,16 @@ You can then import the manifest of your choice:
17
27
  import {NativeReplacements} from 'module-replacements';
18
28
  ```
19
29
 
20
- ## Manifests
30
+ ### Manifests
21
31
 
22
32
  We provide three manifests:
23
33
 
24
34
  - 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)
35
+ - Native replacements
36
+ - Micro utility replacements
37
+ - Preferred replacements
28
38
 
29
- ### Native replacements
39
+ #### Native replacements
30
40
 
31
41
  These are modules which can now be replaced by native functionality.
32
42
 
@@ -36,19 +46,20 @@ platform features can be replaced by their platform equivalents.
36
46
  Similarly, features which did not exist at the time but have now existed in
37
47
  the platform for many years, so no longer need a dependency.
38
48
 
39
- ### Optimisation replacements
49
+ #### Micro utility replacements
40
50
 
41
- These are modules which have more optimal replacements.
51
+ This is a more opinionated list of modules considered to be 'micro utilities' -
52
+ very small utilities which could possibly be replaced with native equivalents
53
+ or removed entirely.
42
54
 
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.
55
+ #### Preferred replacements
46
56
 
47
- Another example - modules which are too granularly modularised, leading to
48
- unnecessarily large amounts of small dependencies (aka "micro dependencies").
57
+ This is a very opinionated list of modules with preferred replacements. Often
58
+ these replacements are much lighter or more modern than the modules they are
59
+ replacing.
49
60
 
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.
61
+ Sometimes these may also be forks of older packages which are actively
62
+ maintained (unlike the source module).
52
63
 
53
64
  # Contributing
54
65
 
@@ -1,18 +1,6 @@
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;
1
+ import { ManifestModule } from './types.js';
2
+ declare const nativeReplacements: ManifestModule;
3
+ declare const microUtilsReplacements: ManifestModule;
4
+ declare const preferredReplacements: ManifestModule;
5
+ export { nativeReplacements, microUtilsReplacements, preferredReplacements };
6
+ export declare const all: ManifestModule;
@@ -3,14 +3,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.all = exports.optimisationReplacements = exports.nativeReplacements = void 0;
6
+ exports.all = exports.preferredReplacements = exports.microUtilsReplacements = exports.nativeReplacements = void 0;
7
7
  const native_json_1 = __importDefault(require("../manifests/native.json"));
8
- const optimisation_json_1 = __importDefault(require("../manifests/optimisation.json"));
8
+ const micro_utilities_json_1 = __importDefault(require("../manifests/micro-utilities.json"));
9
+ const preferred_json_1 = __importDefault(require("../manifests/preferred.json"));
9
10
  const nativeReplacements = native_json_1.default;
10
11
  exports.nativeReplacements = nativeReplacements;
11
- const optimisationReplacements = optimisation_json_1.default;
12
- exports.optimisationReplacements = optimisationReplacements;
12
+ const microUtilsReplacements = micro_utilities_json_1.default;
13
+ exports.microUtilsReplacements = microUtilsReplacements;
14
+ const preferredReplacements = preferred_json_1.default;
15
+ exports.preferredReplacements = preferredReplacements;
13
16
  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]
17
+ moduleReplacements: [
18
+ ...nativeReplacements.moduleReplacements,
19
+ ...microUtilsReplacements.moduleReplacements,
20
+ ...preferredReplacements.moduleReplacements
21
+ ]
16
22
  };
@@ -0,0 +1,27 @@
1
+ interface ModuleReplacementLike {
2
+ type: string;
3
+ moduleName: string;
4
+ category?: string;
5
+ }
6
+ interface DocumentedModuleReplacement extends ModuleReplacementLike {
7
+ type: 'documented';
8
+ docPath: string;
9
+ }
10
+ interface NativeModuleReplacement extends ModuleReplacementLike {
11
+ type: 'native';
12
+ mdnPath: string;
13
+ nodeVersion: string;
14
+ replacement: string;
15
+ }
16
+ interface SimpleModuleReplacement extends ModuleReplacementLike {
17
+ type: 'simple';
18
+ replacement: string;
19
+ }
20
+ interface NoModuleReplacement extends ModuleReplacementLike {
21
+ type: 'none';
22
+ }
23
+ type ModuleReplacement = DocumentedModuleReplacement | NativeModuleReplacement | SimpleModuleReplacement | NoModuleReplacement;
24
+ export interface ManifestModule {
25
+ moduleReplacements: ModuleReplacement[];
26
+ }
27
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,18 +1,6 @@
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;
1
+ import { ManifestModule } from './types.js';
2
+ declare const nativeReplacements: ManifestModule;
3
+ declare const microUtilsReplacements: ManifestModule;
4
+ declare const preferredReplacements: ManifestModule;
5
+ export { nativeReplacements, microUtilsReplacements, preferredReplacements };
6
+ export declare const all: ManifestModule;
package/dist/esm/main.js CHANGED
@@ -1,9 +1,14 @@
1
1
  import native from '../manifests/native.json';
2
- import optimisation from '../manifests/optimisation.json';
2
+ import microUtils from '../manifests/micro-utilities.json';
3
+ import preferred from '../manifests/preferred.json';
3
4
  const nativeReplacements = native;
4
- const optimisationReplacements = optimisation;
5
- export { nativeReplacements, optimisationReplacements };
5
+ const microUtilsReplacements = microUtils;
6
+ const preferredReplacements = preferred;
7
+ export { nativeReplacements, microUtilsReplacements, preferredReplacements };
6
8
  export const all = {
7
- modules: [...native.modules, ...optimisation.modules],
8
- replacements: [...native.replacements, ...optimisation.replacements]
9
+ moduleReplacements: [
10
+ ...nativeReplacements.moduleReplacements,
11
+ ...microUtilsReplacements.moduleReplacements,
12
+ ...preferredReplacements.moduleReplacements
13
+ ]
9
14
  };
@@ -0,0 +1,27 @@
1
+ interface ModuleReplacementLike {
2
+ type: string;
3
+ moduleName: string;
4
+ category?: string;
5
+ }
6
+ interface DocumentedModuleReplacement extends ModuleReplacementLike {
7
+ type: 'documented';
8
+ docPath: string;
9
+ }
10
+ interface NativeModuleReplacement extends ModuleReplacementLike {
11
+ type: 'native';
12
+ mdnPath: string;
13
+ nodeVersion: string;
14
+ replacement: string;
15
+ }
16
+ interface SimpleModuleReplacement extends ModuleReplacementLike {
17
+ type: 'simple';
18
+ replacement: string;
19
+ }
20
+ interface NoModuleReplacement extends ModuleReplacementLike {
21
+ type: 'none';
22
+ }
23
+ type ModuleReplacement = DocumentedModuleReplacement | NativeModuleReplacement | SimpleModuleReplacement | NoModuleReplacement;
24
+ export interface ManifestModule {
25
+ moduleReplacements: ModuleReplacement[];
26
+ }
27
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "module-replacements",
3
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",
4
+ "version": "2.0.0-beta.1",
5
5
  "main": "./dist/commonjs/main.js",
6
6
  "scripts": {
7
7
  "clean": "rimraf dist main.js",
@@ -9,7 +9,9 @@
9
9
  "format": "prettier --write \"./src/**/*.ts\" \"./manifests/**/*.json\"",
10
10
  "build:types": "tsc --noEmit",
11
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"
12
+ "build": "npm run clean && npm run build:bundle && npm run build:types",
13
+ "validate-manifests": "node scripts/validate-manifests.js",
14
+ "generate-schema": "node scripts/generate-schema.js"
13
15
  },
14
16
  "tshy": {
15
17
  "exports": {
@@ -31,9 +33,11 @@
31
33
  },
32
34
  "homepage": "https://github.com/es-tooling/module-replacements#readme",
33
35
  "devDependencies": {
36
+ "ajv": "^8.16.0",
34
37
  "esbuild": "^0.20.0",
35
38
  "prettier": "^3.2.4",
36
39
  "rimraf": "^5.0.5",
40
+ "ts-json-schema-generator": "^2.3.0",
37
41
  "tshy": "^1.11.0",
38
42
  "typescript": "^5.3.3"
39
43
  },