@module-federation/sdk 0.3.0 → 0.3.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.
Files changed (40) hide show
  1. package/README.md +99 -0
  2. package/dist/LICENSE +21 -0
  3. package/dist/index.cjs.js +749 -0
  4. package/dist/index.esm.js +701 -0
  5. package/dist/normalize-webpack-path.cjs.js +48 -0
  6. package/dist/normalize-webpack-path.esm.js +39 -0
  7. package/dist/package.json +44 -0
  8. package/{src → dist/src}/constant.d.ts +9 -0
  9. package/dist/src/dom.d.ts +30 -0
  10. package/{src → dist/src}/generateSnapshotFromManifest.d.ts +1 -0
  11. package/dist/src/index.d.ts +9 -0
  12. package/dist/src/node.d.ts +5 -0
  13. package/{src → dist/src}/normalize-webpack-path.d.ts +3 -1
  14. package/dist/src/normalizeOptions.d.ts +1 -0
  15. package/{src → dist/src}/types/index.d.ts +1 -0
  16. package/dist/src/types/plugins/ContainerPlugin.d.ts +159 -0
  17. package/dist/src/types/plugins/ContainerReferencePlugin.d.ts +52 -0
  18. package/dist/src/types/plugins/ModuleFederationPlugin.d.ts +334 -0
  19. package/dist/src/types/plugins/SharePlugin.d.ts +71 -0
  20. package/dist/src/types/plugins/index.d.ts +4 -0
  21. package/{src → dist/src}/types/snapshot.d.ts +7 -0
  22. package/{src → dist/src}/types/stats.d.ts +15 -5
  23. package/{src → dist/src}/utils.d.ts +1 -1
  24. package/package.json +14 -11
  25. package/index.cjs.default.js +0 -1
  26. package/index.cjs.js +0 -793
  27. package/index.cjs.mjs +0 -2
  28. package/index.esm.js +0 -761
  29. package/normalize-webpack-path.cjs.default.js +0 -1
  30. package/normalize-webpack-path.cjs.js +0 -42
  31. package/normalize-webpack-path.cjs.mjs +0 -2
  32. package/normalize-webpack-path.esm.js +0 -33
  33. package/src/dom.d.ts +0 -10
  34. package/src/index.d.ts +0 -7
  35. /package/{index.cjs.d.ts → dist/index.cjs.d.ts} +0 -0
  36. /package/{normalize-webpack-path.cjs.d.ts → dist/normalize-webpack-path.cjs.d.ts} +0 -0
  37. /package/{src → dist/src}/env.d.ts +0 -0
  38. /package/{src → dist/src}/logger.d.ts +0 -0
  39. /package/{src → dist/src}/types/common.d.ts +0 -0
  40. /package/{src → dist/src}/types/manifest.d.ts +0 -0
package/README.md ADDED
@@ -0,0 +1,99 @@
1
+ # `@module-federation/sdk` Documentation
2
+
3
+ - This SDK provides utilities and tools to support the implementation of Module Federation in your projects.
4
+ - It contains utility functions for parsing, encoding, and decoding module names, as well as generating filenames for exposed modules and shared packages.
5
+ - It also includes a logger for debugging and environment detection utilities.
6
+ - Additionally, it provides a function to generate a snapshot from a manifest and environment detection utilities.
7
+
8
+ ## Usage
9
+
10
+ ```javascript
11
+ // The SDK can be used to parse entry strings, encode and decode module names, and generate filenames for exposed modules and shared packages.
12
+ // It also includes a logger for debugging and environment detection utilities.
13
+ // Additionally, it provides a function to generate a snapshot from a manifest and environment detection utilities.
14
+ import { parseEntry, encodeName, decodeName, generateExposeFilename, generateShareFilename, Logger, isBrowserEnv, isDebugMode, getProcessEnv, generateSnapshotFromManifest } from '@module-federation/sdk';
15
+
16
+ // Parse an entry string into a RemoteEntryInfo object
17
+ parseEntry('entryString');
18
+
19
+ // Encode a module name with a prefix and optional extension
20
+ encodeName('moduleName', 'prefix');
21
+
22
+ // Decode a module name with a prefix and optional extension
23
+ decodeName('encodedModuleName', 'prefix');
24
+
25
+ // Generate a filename for an exposed module
26
+ generateExposeFilename('exposeName', true);
27
+
28
+ // Generate a filename for a shared package
29
+ generateShareFilename('packageName', true);
30
+
31
+ // Create a new logger
32
+ const logger = new Logger('identifier');
33
+
34
+ // Check if the current environment is a browser
35
+ isBrowserEnv();
36
+
37
+ // Check if the current environment is in debug mode
38
+ isDebugMode();
39
+
40
+ // Get the process environment
41
+ getProcessEnv();
42
+
43
+ // Generate a snapshot from a manifest
44
+ generateSnapshotFromManifest(manifest, options);
45
+ ```
46
+
47
+ ### parseEntry
48
+
49
+ - Type: `parseEntry(str: string, devVerOrUrl?: string)`
50
+ - Parses a string into a RemoteEntryInfo object.
51
+
52
+ ### encodeName
53
+
54
+ - Type: `encodeName(name: string, prefix = '', withExt = false)`
55
+ - Encodes a name with a prefix and optional extension.
56
+
57
+ ### decodeName
58
+
59
+ - Type: `decodeName(name: string, prefix?: string, withExt?: boolean)`
60
+ - Decodes a name with a prefix and optional extension.
61
+
62
+ ### generateExposeFilename
63
+
64
+ - Type: `generateExposeFilename(exposeName: string, withExt: boolean)`
65
+ - Generates a filename for an expose.
66
+
67
+ ### generateShareFilename
68
+
69
+ - Type: `generateShareFilename(pkgName: string, withExt: boolean)`
70
+ - Generates a filename for a shared package.
71
+
72
+ ### Logger
73
+
74
+ - Type: `new Logger(identifier?: string)`
75
+ - Creates a new logger for debugging.
76
+
77
+ ### isBrowserEnv
78
+
79
+ - Type: `isBrowserEnv()`
80
+ - Checks if the current environment is a browser.
81
+
82
+ ### isDebugMode
83
+
84
+ - Type: `isDebugMode()`
85
+ - Checks if the current environment is in debug mode.
86
+
87
+ ### getProcessEnv
88
+
89
+ - Type: `getProcessEnv()`
90
+ - Gets the process environment.
91
+
92
+ ### generateSnapshotFromManifest
93
+
94
+ - Type: `generateSnapshotFromManifest(manifest: Manifest, options: IOptions = {})`
95
+ - Generates a snapshot from a manifest.
96
+
97
+ ## Testing
98
+
99
+ The SDK uses Jest for testing. The configuration can be found in `jest.config.js`. The tests are located in the **tests** directory.
package/dist/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-present zhanghang(2heal1)
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.