@module-federation/nextjs-mf 0.0.0-feat-node-support-1702694175665

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 (91) hide show
  1. package/client/UrlNode.d.ts +17 -0
  2. package/client/UrlNode.js +150 -0
  3. package/client/UrlNode.js.map +1 -0
  4. package/node.d.ts +1 -0
  5. package/node.js +18 -0
  6. package/node.js.map +1 -0
  7. package/package.json +44 -0
  8. package/src/default-delegate.cjs +308 -0
  9. package/src/default-delegate.d.ts +1 -0
  10. package/src/default-delegate.js.map +1 -0
  11. package/src/federation-noop.cjs +15 -0
  12. package/src/federation-noop.d.ts +0 -0
  13. package/src/federation-noop.js.map +1 -0
  14. package/src/index.d.ts +3 -0
  15. package/src/index.js +12 -0
  16. package/src/index.js.map +1 -0
  17. package/src/internal.d.ts +48 -0
  18. package/src/internal.js +256 -0
  19. package/src/internal.js.map +1 -0
  20. package/src/loaders/delegateLoader.d.ts +10 -0
  21. package/src/loaders/delegateLoader.js +46 -0
  22. package/src/loaders/delegateLoader.js.map +1 -0
  23. package/src/loaders/fixImageLoader.d.ts +22 -0
  24. package/src/loaders/fixImageLoader.js +118 -0
  25. package/src/loaders/fixImageLoader.js.map +1 -0
  26. package/src/loaders/fixUrlLoader.d.ts +13 -0
  27. package/src/loaders/fixUrlLoader.js +25 -0
  28. package/src/loaders/fixUrlLoader.js.map +1 -0
  29. package/src/loaders/helpers.d.ts +17 -0
  30. package/src/loaders/helpers.js +60 -0
  31. package/src/loaders/helpers.js.map +1 -0
  32. package/src/loaders/nextPageMapLoader.d.ts +24 -0
  33. package/src/loaders/nextPageMapLoader.js +167 -0
  34. package/src/loaders/nextPageMapLoader.js.map +1 -0
  35. package/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.d.ts +5 -0
  36. package/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js +19 -0
  37. package/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js.map +1 -0
  38. package/src/plugins/CopyFederationPlugin.d.ts +20 -0
  39. package/src/plugins/CopyFederationPlugin.js +71 -0
  40. package/src/plugins/CopyFederationPlugin.js.map +1 -0
  41. package/src/plugins/NextFederationPlugin/apply-client-plugins.d.ts +23 -0
  42. package/src/plugins/NextFederationPlugin/apply-client-plugins.js +72 -0
  43. package/src/plugins/NextFederationPlugin/apply-client-plugins.js.map +1 -0
  44. package/src/plugins/NextFederationPlugin/apply-server-plugins.d.ts +60 -0
  45. package/src/plugins/NextFederationPlugin/apply-server-plugins.js +173 -0
  46. package/src/plugins/NextFederationPlugin/apply-server-plugins.js.map +1 -0
  47. package/src/plugins/NextFederationPlugin/index.d.ts +30 -0
  48. package/src/plugins/NextFederationPlugin/index.js +148 -0
  49. package/src/plugins/NextFederationPlugin/index.js.map +1 -0
  50. package/src/plugins/NextFederationPlugin/next-fragments.d.ts +18 -0
  51. package/src/plugins/NextFederationPlugin/next-fragments.js +65 -0
  52. package/src/plugins/NextFederationPlugin/next-fragments.js.map +1 -0
  53. package/src/plugins/NextFederationPlugin/regex-equal.d.ts +14 -0
  54. package/src/plugins/NextFederationPlugin/regex-equal.js +25 -0
  55. package/src/plugins/NextFederationPlugin/regex-equal.js.map +1 -0
  56. package/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.d.ts +8 -0
  57. package/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js +31 -0
  58. package/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js.map +1 -0
  59. package/src/plugins/NextFederationPlugin/set-options.d.ts +20 -0
  60. package/src/plugins/NextFederationPlugin/set-options.js +38 -0
  61. package/src/plugins/NextFederationPlugin/set-options.js.map +1 -0
  62. package/src/plugins/NextFederationPlugin/validate-options.d.ts +25 -0
  63. package/src/plugins/NextFederationPlugin/validate-options.js +46 -0
  64. package/src/plugins/NextFederationPlugin/validate-options.js.map +1 -0
  65. package/src/plugins/container/EmbeddedContainerPlugin.d.ts +40 -0
  66. package/src/plugins/container/EmbeddedContainerPlugin.js +73 -0
  67. package/src/plugins/container/EmbeddedContainerPlugin.js.map +1 -0
  68. package/src/plugins/container/HoistPseudoEagerModules.d.ts +19 -0
  69. package/src/plugins/container/HoistPseudoEagerModules.js +79 -0
  70. package/src/plugins/container/HoistPseudoEagerModules.js.map +1 -0
  71. package/src/plugins/container/InvertedContainerPlugin.d.ts +15 -0
  72. package/src/plugins/container/InvertedContainerPlugin.js +25 -0
  73. package/src/plugins/container/InvertedContainerPlugin.js.map +1 -0
  74. package/src/plugins/container/InvertedContainerRuntimeModule.d.ts +15 -0
  75. package/src/plugins/container/InvertedContainerRuntimeModule.js +65 -0
  76. package/src/plugins/container/InvertedContainerRuntimeModule.js.map +1 -0
  77. package/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.d.ts +39 -0
  78. package/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js +72 -0
  79. package/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js.map +1 -0
  80. package/src/plugins/container/runtimePlugin.d.ts +2 -0
  81. package/src/plugins/container/runtimePlugin.js +64 -0
  82. package/src/plugins/container/runtimePlugin.js.map +1 -0
  83. package/src/plugins/container/types.d.ts +2 -0
  84. package/src/plugins/container/types.js +3 -0
  85. package/src/plugins/container/types.js.map +1 -0
  86. package/src/types.d.ts +28 -0
  87. package/src/types.js +3 -0
  88. package/src/types.js.map +1 -0
  89. package/utilities.d.ts +1 -0
  90. package/utilities.js +18 -0
  91. package/utilities.js.map +1 -0
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validatePluginOptions = exports.validateCompilerOptions = void 0;
4
+ /**
5
+ * Validates the compiler options.
6
+ *
7
+ * @param {Compiler} compiler - The Webpack compiler instance.
8
+ * @returns {boolean} - Returns true if the compiler options are valid, false otherwise.
9
+ *
10
+ * @throws Will throw an error if the name option is not defined in the options.
11
+ * @remarks
12
+ * This function validates the options passed to the Webpack compiler. It checks if the name option is set to either "server" or
13
+ * "client", as Module Federation is only applied to the main server and client builds in Next.js.
14
+ */
15
+ function validateCompilerOptions(compiler) {
16
+ // Throw an error if the name option is not defined in the options
17
+ if (!compiler.options.name) {
18
+ throw new Error('name is not defined in Compiler options');
19
+ }
20
+ // Only apply Module Federation to the main server and client builds in Next.js
21
+ return ['server', 'client'].includes(compiler.options.name);
22
+ }
23
+ exports.validateCompilerOptions = validateCompilerOptions;
24
+ /**
25
+ * Validates the NextFederationPlugin options.
26
+ *
27
+ * @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
28
+ *
29
+ * @throws Will throw an error if the filename option is not defined in the options or if the name option is not specified.
30
+ * @remarks
31
+ * This function validates the options passed to NextFederationPlugin. It ensures that the filename and name options are defined,
32
+ * as they are required for using Module Federation.
33
+ */
34
+ function validatePluginOptions(options) {
35
+ // Throw an error if the filename option is not defined in the options
36
+ if (!options.filename) {
37
+ throw new Error('filename is not defined in NextFederation options');
38
+ }
39
+ // A requirement for using Module Federation is that a name must be specified
40
+ if (!options.name) {
41
+ throw new Error('Module federation "name" option must be specified');
42
+ }
43
+ return true;
44
+ }
45
+ exports.validatePluginOptions = validatePluginOptions;
46
+ //# sourceMappingURL=validate-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-options.js","sourceRoot":"","sources":["../../../../../../packages/nextjs-mf/src/plugins/NextFederationPlugin/validate-options.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;GAUG;AACH,SAAgB,uBAAuB,CAAC,QAAkB;IACxD,kEAAkE;IAClE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE;QAC1B,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;KAC5D;IAED,+EAA+E;IAC/E,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC9D,CAAC;AARD,0DAQC;AAED;;;;;;;;;GASG;AACH,SAAgB,qBAAqB,CACnC,OAAsC;IAEtC,sEAAsE;IACtE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;KACtE;IAED,6EAA6E;IAC7E,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;KACtE;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAbD,sDAaC"}
@@ -0,0 +1,40 @@
1
+ import type { Compiler } from 'webpack';
2
+ /**
3
+ * @typedef {Object} EmbeddedContainerOptions
4
+ * @property {string} runtime - The runtime of the plugin
5
+ * @property {string} [container] - The container of the plugin
6
+ * @property {string} chunkToEmbed - The chunk to embed in the plugin
7
+ */
8
+ export interface EmbeddedContainerOptions {
9
+ runtime: string;
10
+ container?: string;
11
+ chunkToEmbed: string;
12
+ }
13
+ /**
14
+ * EmbeddedContainerPlugin class for Webpack.
15
+ * @class
16
+ */
17
+ declare class EmbeddedContainerPlugin {
18
+ private options;
19
+ /**
20
+ * Constructor for the EmbeddedContainerPlugin.
21
+ * @param {EmbeddedContainerOptions} options - The options for the plugin
22
+ */
23
+ constructor(options: EmbeddedContainerOptions);
24
+ /**
25
+ * Process the given chunks.
26
+ * @param {Iterable<Chunk>} chunks - The chunks to process
27
+ * @param {Compilation} compilation - The compilation of the plugin
28
+ * @returns {void}
29
+ * @private
30
+ */
31
+ private processChunks;
32
+ /**
33
+ * Apply the plugin to the given compiler.
34
+ * @param {Compiler} compiler - The compiler to apply the plugin to
35
+ * @returns {void}
36
+ * @public
37
+ */
38
+ apply(compiler: Compiler): void;
39
+ }
40
+ export default EmbeddedContainerPlugin;
@@ -0,0 +1,73 @@
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
+ const InvertedContainerRuntimeModule_1 = __importDefault(require("./InvertedContainerRuntimeModule"));
7
+ /**
8
+ * EmbeddedContainerPlugin class for Webpack.
9
+ * @class
10
+ */
11
+ class EmbeddedContainerPlugin {
12
+ /**
13
+ * Constructor for the EmbeddedContainerPlugin.
14
+ * @param {EmbeddedContainerOptions} options - The options for the plugin
15
+ */
16
+ constructor(options) {
17
+ this.options = options;
18
+ }
19
+ /**
20
+ * Process the given chunks.
21
+ * @param {Iterable<Chunk>} chunks - The chunks to process
22
+ * @param {Compilation} compilation - The compilation of the plugin
23
+ * @returns {void}
24
+ * @private
25
+ */
26
+ processChunks(chunks, compilation) {
27
+ const relevantChunks = new Map();
28
+ for (const chunk of chunks) {
29
+ if (chunk.name &&
30
+ [
31
+ this.options.runtime,
32
+ this.options.container,
33
+ this.options.chunkToEmbed,
34
+ ].includes(chunk.name)) {
35
+ relevantChunks.set(chunk.name, chunk);
36
+ }
37
+ }
38
+ const runtimeChunk = relevantChunks.get(this.options.runtime);
39
+ const partialContainerChunk = relevantChunks.get(this.options.chunkToEmbed);
40
+ if (partialContainerChunk && runtimeChunk) {
41
+ const chunkGraph = compilation.chunkGraph;
42
+ for (const module of chunkGraph.getChunkModulesIterable(partialContainerChunk)) {
43
+ chunkGraph.connectChunkAndModule(runtimeChunk, module);
44
+ chunkGraph.disconnectChunkAndModule(partialContainerChunk, module);
45
+ }
46
+ }
47
+ }
48
+ /**
49
+ * Apply the plugin to the given compiler.
50
+ * @param {Compiler} compiler - The compiler to apply the plugin to
51
+ * @returns {void}
52
+ * @public
53
+ */
54
+ apply(compiler) {
55
+ compiler.hooks.thisCompilation.tap('EmbeddedContainerPlugin', (compilation) => {
56
+ // Hook into the optimizeChunks phase
57
+ compilation.hooks.optimizeChunks.tap('EmbeddedContainerPlugin', (chunks) => this.processChunks(chunks, compilation));
58
+ // Add the runtime module
59
+ compilation.hooks.additionalTreeRuntimeRequirements.tap('EmbeddedContainerPlugin', (chunk, set) => {
60
+ const runtimeModuleOptions = {
61
+ runtime: this.options.runtime,
62
+ remotes: {},
63
+ name: this.options.container,
64
+ debug: false,
65
+ container: this.options.container,
66
+ };
67
+ compilation.addRuntimeModule(chunk, new InvertedContainerRuntimeModule_1.default(runtimeModuleOptions));
68
+ });
69
+ });
70
+ }
71
+ }
72
+ exports.default = EmbeddedContainerPlugin;
73
+ //# sourceMappingURL=EmbeddedContainerPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmbeddedContainerPlugin.js","sourceRoot":"","sources":["../../../../../../packages/nextjs-mf/src/plugins/container/EmbeddedContainerPlugin.ts"],"names":[],"mappings":";;;;;AACA,sGAA8E;AAc9E;;;GAGG;AACH,MAAM,uBAAuB;IAG3B;;;OAGG;IACH,YAAY,OAAiC;QAC3C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;;;;;OAMG;IACK,aAAa,CACnB,MAAuB,EACvB,WAAwB;QAExB,MAAM,cAAc,GAAG,IAAI,GAAG,EAAE,CAAC;QACjC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;YAC1B,IACE,KAAK,CAAC,IAAI;gBACV;oBACE,IAAI,CAAC,OAAO,CAAC,OAAO;oBACpB,IAAI,CAAC,OAAO,CAAC,SAAS;oBACtB,IAAI,CAAC,OAAO,CAAC,YAAY;iBAC1B,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,EACtB;gBACA,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;aACvC;SACF;QAED,MAAM,YAAY,GAAG,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC9D,MAAM,qBAAqB,GAAG,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAE5E,IAAI,qBAAqB,IAAI,YAAY,EAAE;YACzC,MAAM,UAAU,GAAG,WAAW,CAAC,UAAU,CAAC;YAC1C,KAAK,MAAM,MAAM,IAAI,UAAU,CAAC,uBAAuB,CACrD,qBAAqB,CACtB,EAAE;gBACD,UAAU,CAAC,qBAAqB,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;gBACvD,UAAU,CAAC,wBAAwB,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;aACpE;SACF;IACH,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,QAAkB;QAC7B,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,GAAG,CAChC,yBAAyB,EACzB,CAAC,WAAwB,EAAE,EAAE;YAC3B,qCAAqC;YACrC,WAAW,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAClC,yBAAyB,EACzB,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,WAAW,CAAC,CACpD,CAAC;YAEF,yBAAyB;YACzB,WAAW,CAAC,KAAK,CAAC,iCAAiC,CAAC,GAAG,CACrD,yBAAyB,EACzB,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;gBACb,MAAM,oBAAoB,GAAG;oBAC3B,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;oBAC7B,OAAO,EAAE,EAAE;oBACX,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS;oBAC5B,KAAK,EAAE,KAAK;oBACZ,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS;iBAClC,CAAC;gBAEF,WAAW,CAAC,gBAAgB,CAC1B,KAAK,EACL,IAAI,wCAA8B,CAAC,oBAAoB,CAAC,CACzD,CAAC;YACJ,CAAC,CACF,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AAED,kBAAe,uBAAuB,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { Compiler } from 'webpack';
2
+ /**
3
+ * @typedef {import("webpack").Compiler} Compiler
4
+ * @typedef {import("webpack").Compilation} Compilation
5
+ * @typedef {import("webpack").Chunk} Chunk
6
+ * @typedef {import("webpack").Module} Module
7
+ */
8
+ /**
9
+ * This class is responsible for hoisting container references in the code.
10
+ * @constructor
11
+ */
12
+ export declare class HoistPseudoEager {
13
+ /**
14
+ * @function apply
15
+ * @param {Compiler} compiler The webpack compiler object
16
+ */
17
+ apply(compiler: Compiler): void;
18
+ }
19
+ export default HoistPseudoEager;
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HoistPseudoEager = void 0;
4
+ /**
5
+ * @typedef {import("webpack").Compiler} Compiler
6
+ * @typedef {import("webpack").Compilation} Compilation
7
+ * @typedef {import("webpack").Chunk} Chunk
8
+ * @typedef {import("webpack").Module} Module
9
+ */
10
+ /**
11
+ * This class is responsible for hoisting container references in the code.
12
+ * @constructor
13
+ */
14
+ class HoistPseudoEager {
15
+ /**
16
+ * @function apply
17
+ * @param {Compiler} compiler The webpack compiler object
18
+ */
19
+ apply(compiler) {
20
+ // Hook into the compilation process
21
+ compiler.hooks.thisCompilation.tap('HoistPseudoEager', (compilation) => {
22
+ // Perform the hoisting after chunks are optimized
23
+ compilation.hooks.afterOptimizeChunks.tap('HoistPseudoEager', (chunks, chunkGroups) => {
24
+ // Create a map to store chunks by their id or name
25
+ /** @type {Map<(string|number), Chunk>} */
26
+ const chunkSet = new Map();
27
+ // Create a set to store external module requests
28
+ /** @type {Set<Module>} */
29
+ const externalRequests = new Set();
30
+ // Populate the chunkSet with chunks
31
+ for (const chunk of chunks) {
32
+ const ident = chunk.id || chunk.name;
33
+ if (ident) {
34
+ chunkSet.set(ident, chunk);
35
+ }
36
+ }
37
+ // Iterate over chunks again to handle remote modules
38
+ for (const chunk of chunks) {
39
+ // Get iterable of remote modules for the chunk
40
+ const remoteModules = compilation.chunkGraph.getChunkModulesIterableBySourceType(chunk, 'remote');
41
+ if (!remoteModules)
42
+ continue;
43
+ const runtime = chunkSet.get('webpack-runtime') || chunkSet.get('webpack');
44
+ const runtimeRoots = runtime
45
+ ? compilation.chunkGraph.getChunkRootModules(runtime)
46
+ : null;
47
+ const refChunks = runtime
48
+ ? Array.from(runtime.getAllReferencedChunks())
49
+ : null;
50
+ if (refChunks) {
51
+ for (const refChunk of refChunks) {
52
+ const consumeSharedModules = compilation.chunkGraph.getChunkModulesIterableBySourceType(refChunk, 'consume-shared');
53
+ if (!consumeSharedModules)
54
+ continue;
55
+ //loop through consume-shared modules
56
+ for (const module of consumeSharedModules) {
57
+ // Get the module associated with the dependency
58
+ for (const block of module.blocks) {
59
+ for (const dep of block.dependencies) {
60
+ const mod = compilation.moduleGraph.getModule(dep);
61
+ // If the module exists and the chunk has a runtime, add the module to externalRequests
62
+ if (mod !== null && runtime) {
63
+ // Get the runtime chunk from the chunkSet
64
+ // If the runtime chunk exists, connect it with the module in the chunk graph
65
+ compilation.chunkGraph.connectChunkAndModule(runtime, mod);
66
+ }
67
+ }
68
+ }
69
+ }
70
+ }
71
+ }
72
+ }
73
+ });
74
+ });
75
+ }
76
+ }
77
+ exports.HoistPseudoEager = HoistPseudoEager;
78
+ exports.default = HoistPseudoEager;
79
+ //# sourceMappingURL=HoistPseudoEagerModules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HoistPseudoEagerModules.js","sourceRoot":"","sources":["../../../../../../packages/nextjs-mf/src/plugins/container/HoistPseudoEagerModules.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AAEH;;;GAGG;AACH,MAAa,gBAAgB;IAC3B;;;OAGG;IACH,KAAK,CAAC,QAAkB;QACtB,oCAAoC;QACpC,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,GAAG,CAChC,kBAAkB,EAClB,CAAC,WAAwB,EAAE,EAAE;YAC3B,kDAAkD;YAClD,WAAW,CAAC,KAAK,CAAC,mBAAmB,CAAC,GAAG,CACvC,kBAAkB,EAClB,CAAC,MAAuB,EAAE,WAAyB,EAAE,EAAE;gBACrD,mDAAmD;gBACnD,0CAA0C;gBAC1C,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA0B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AAI,MAAM,CAAC,MAAM,EAAE;oCACjC,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,YAAY,EAAE;wCACpC,MAAM,GAAG,GAAG,WAAW,CAAC,WAAW,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;wCACnD,uFAAuF;wCACvF,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,EAAE;4CAC3B,0CAA0C;4CAC1C,6EAA6E;4CAC7E,WAAW,CAAC,UAAU,CAAC,qBAAqB,CAC1C,OAAO,EACP,GAAG,CACJ,CAAC;yCACH;qCACF;iCACF;6BACF;yBACF;qBACF;iBACF;YACH,CAAC,CACF,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AA/ED,4CA+EC;AACD,kBAAe,gBAAgB,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { Compiler } from 'webpack';
2
+ import { ModuleFederationPluginOptions } from './types';
3
+ interface InvertedContainerOptions extends ModuleFederationPluginOptions {
4
+ container?: string;
5
+ remotes: Record<string, string>;
6
+ runtime: string;
7
+ debug?: boolean;
8
+ chunkToEmbed: string;
9
+ }
10
+ declare class InvertedContainerPlugin {
11
+ private options;
12
+ constructor(options: InvertedContainerOptions);
13
+ apply(compiler: Compiler): void;
14
+ }
15
+ export default InvertedContainerPlugin;
@@ -0,0 +1,25 @@
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
+ const EmbeddedContainerPlugin_1 = __importDefault(require("./EmbeddedContainerPlugin"));
7
+ const enhanced_1 = require("@module-federation/enhanced");
8
+ class InvertedContainerPlugin {
9
+ constructor(options) {
10
+ this.options = options;
11
+ }
12
+ apply(compiler) {
13
+ new EmbeddedContainerPlugin_1.default({
14
+ runtime: this.options.runtime,
15
+ container: this.options.container,
16
+ chunkToEmbed: this.options.chunkToEmbed,
17
+ }).apply(compiler);
18
+ new enhanced_1.AsyncBoundaryPlugin({
19
+ eager: (module) => /.federation/.test(module.identifier()),
20
+ //@ts-ignore
21
+ }).apply(compiler);
22
+ }
23
+ }
24
+ exports.default = InvertedContainerPlugin;
25
+ //# sourceMappingURL=InvertedContainerPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InvertedContainerPlugin.js","sourceRoot":"","sources":["../../../../../../packages/nextjs-mf/src/plugins/container/InvertedContainerPlugin.ts"],"names":[],"mappings":";;;;;AAEA,wFAAgE;AAChE,0DAAkE;AAUlE,MAAM,uBAAuB;IAG3B,YAAY,OAAiC;QAC3C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAEM,KAAK,CAAC,QAAkB;QAC7B,IAAI,iCAAuB,CAAC;YAC1B,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;YAC7B,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS;YACjC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY;SACxC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEnB,IAAI,8BAAmB,CAAC;YACtB,KAAK,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YAC1D,YAAY;SACb,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACrB,CAAC;CACF;AAED,kBAAe,uBAAuB,CAAC"}
@@ -0,0 +1,15 @@
1
+ declare const RuntimeModule: typeof import("webpack").RuntimeModule;
2
+ interface InvertedContainerRuntimeModuleOptions {
3
+ runtime: string;
4
+ remotes: Record<string, string>;
5
+ name?: string;
6
+ debug?: boolean;
7
+ container?: string;
8
+ }
9
+ declare class InvertedContainerRuntimeModule extends RuntimeModule {
10
+ private options;
11
+ constructor(options: InvertedContainerRuntimeModuleOptions);
12
+ private findEntryModuleOfContainer;
13
+ generate(): string;
14
+ }
15
+ export default InvertedContainerRuntimeModule;
@@ -0,0 +1,65 @@
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
+ const normalize_webpack_path_1 = require("@module-federation/sdk/normalize-webpack-path");
7
+ const ContainerEntryModule_1 = __importDefault(require("@module-federation/enhanced/src/lib/container/ContainerEntryModule"));
8
+ const { RuntimeModule, Template, RuntimeGlobals } = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack'));
9
+ class InvertedContainerRuntimeModule extends RuntimeModule {
10
+ constructor(options) {
11
+ super('inverted container startup', RuntimeModule.STAGE_TRIGGER);
12
+ this.options = options;
13
+ }
14
+ findEntryModuleOfContainer() {
15
+ if (!this.chunk || !this.chunkGraph)
16
+ return undefined;
17
+ const modules = this.chunkGraph.getChunkModules(this.chunk);
18
+ return Array.from(modules).find((module) => module instanceof ContainerEntryModule_1.default);
19
+ }
20
+ generate() {
21
+ if (!this.compilation || !this.chunk || !this.chunkGraph) {
22
+ return '';
23
+ }
24
+ const { name, debug } = this.options;
25
+ const containerEntryModule = this.findEntryModuleOfContainer();
26
+ const chunk = this.chunk;
27
+ const containerModuleId = containerEntryModule?.id || containerEntryModule?.debugId;
28
+ const isPartialContainer = chunk.runtime === this.options.runtime;
29
+ if (!containerModuleId || !isPartialContainer) {
30
+ return '';
31
+ }
32
+ const globalObject = `globalThis.__remote_scope__`;
33
+ const containerScope = `${RuntimeGlobals.global}`;
34
+ return Template.asString([
35
+ 'var innerRemote;',
36
+ Template.indent([
37
+ 'function attachRemote (resolve) {',
38
+ `if(__webpack_require__.m[${JSON.stringify(containerModuleId)}]) {`,
39
+ Template.indent(`innerRemote = __webpack_require__(${JSON.stringify(containerModuleId)});`),
40
+ `}`,
41
+ // can likely remove this logic
42
+ ` if(${globalObject} && !${globalObject}[${JSON.stringify(name)}]) {`,
43
+ ` ${globalObject}[${JSON.stringify(name)}] = innerRemote;`,
44
+ ` } else if(${containerScope} && !${containerScope}[${JSON.stringify(name)}]) {`,
45
+ ` ${containerScope}[${JSON.stringify(name)}] = innerRemote;`,
46
+ ' }',
47
+ ' if(resolve) resolve(innerRemote);',
48
+ `return innerRemote`,
49
+ '}',
50
+ '__webpack_require__.federation.attachRemote = ()=> attachRemote();',
51
+ ]),
52
+ Template.indent([
53
+ ' if (__webpack_require__.O) {',
54
+ ` __webpack_require__.O(0, ["${this.chunk.id}"], function() {`,
55
+ ' attachRemote();',
56
+ ' }, 0);',
57
+ '} else {',
58
+ 'attachRemote();',
59
+ '}',
60
+ ]),
61
+ ]);
62
+ }
63
+ }
64
+ exports.default = InvertedContainerRuntimeModule;
65
+ //# sourceMappingURL=InvertedContainerRuntimeModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InvertedContainerRuntimeModule.js","sourceRoot":"","sources":["../../../../../../packages/nextjs-mf/src/plugins/container/InvertedContainerRuntimeModule.ts"],"names":[],"mappings":";;;;;AAAA,0FAAqF;AAErF,8HAAsG;AAEtG,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,OAAO,CACzD,IAAA,6CAAoB,EAAC,SAAS,CAAC,CACJ,CAAC;AAS9B,MAAM,8BAA+B,SAAQ,aAAa;IAGxD,YAAY,OAA8C;QACxD,KAAK,CAAC,4BAA4B,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;QACjE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAEO,0BAA0B;QAChC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,UAAU;YAAE,OAAO,SAAS,CAAC;QACtD,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAE5D,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAC7B,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,Y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c,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,kBAAkB;gBAC/D,KAAK;gBACL,qCAAqC;gBACrC,oBAAoB;gBACpB,GAAG;gBACH,oEAAoE;aACrE,CAAC;YACF,QAAQ,CAAC,MAAM,CAAC;gBACd,gCAAgC;gBAChC,gCAAgC,IAAI,CAAC,KAAK,CAAC,EAAE,kBAAkB;gBAC/D,qBAAqB;gBACrB,UAAU;gBACV,UAAU;gBACV,iBAAiB;gBACjB,GAAG;aACJ,CAAC;SACH,CAAC,CAAC;IACL,CAAC;CACF;AAED,kBAAe,8BAA8B,CAAC"}
@@ -0,0 +1,39 @@
1
+ import type { Compiler } from 'webpack';
2
+ /**
3
+ * This plugin removes eager modules from the runtime.
4
+ * @class RemoveEagerModulesFromRuntimePlugin
5
+ */
6
+ declare class RemoveEagerModulesFromRuntimePlugin {
7
+ private container;
8
+ private debug;
9
+ private modulesToProcess;
10
+ /**
11
+ * Creates an instance of RemoveEagerModulesFromRuntimePlugin.
12
+ * @param {Object} options - The options for the plugin.
13
+ * @param {string} options.container - The container to remove modules from.
14
+ * @param {boolean} options.debug - Whether to log debug information.
15
+ */
16
+ constructor(options: {
17
+ container?: string;
18
+ debug?: boolean;
19
+ });
20
+ /**
21
+ * Applies the plugin to the compiler.
22
+ * @param {Compiler} compiler - The webpack compiler.
23
+ */
24
+ apply(compiler: Compiler): void;
25
+ /**
26
+ * Processes the modules in the chunk.
27
+ * @param {Compilation} compilation - The webpack compilation.
28
+ * @param {Chunk} chunk - The chunk to process.
29
+ * @param {Iterable<Module>} modules - The modules in the chunk.
30
+ */
31
+ private processModules;
32
+ /**
33
+ * Removes the modules from the chunk.
34
+ * @param {Compilation} compilation - The webpack compilation.
35
+ * @param {Chunk} chunk - The chunk to remove modules from.
36
+ */
37
+ private removeModules;
38
+ }
39
+ export default RemoveEagerModulesFromRuntimePlugin;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * This plugin removes eager modules from the runtime.
5
+ * @class RemoveEagerModulesFromRuntimePlugin
6
+ */
7
+ class RemoveEagerModulesFromRuntimePlugin {
8
+ /**
9
+ * Creates an instance of RemoveEagerModulesFromRuntimePlugin.
10
+ * @param {Object} options - The options for the plugin.
11
+ * @param {string} options.container - The container to remove modules from.
12
+ * @param {boolean} options.debug - Whether to log debug information.
13
+ */
14
+ constructor(options) {
15
+ this.container = options.container;
16
+ this.debug = options.debug || false;
17
+ this.modulesToProcess = new Set();
18
+ }
19
+ /**
20
+ * Applies the plugin to the compiler.
21
+ * @param {Compiler} compiler - The webpack compiler.
22
+ */
23
+ apply(compiler) {
24
+ if (!this.container) {
25
+ console.warn('[nextjs-mf]:', 'RemoveEagerModulesFromRuntimePlugin container is not defined:', this.container);
26
+ return;
27
+ }
28
+ compiler.hooks.thisCompilation.tap('RemoveEagerModulesFromRuntimePlugin', (compilation) => {
29
+ compilation.hooks.optimizeChunkModules.tap('RemoveEagerModulesFromRuntimePlugin', (chunks, modules) => {
30
+ for (const chunk of chunks) {
31
+ if (chunk.hasRuntime() && chunk.name === this.container) {
32
+ this.processModules(compilation, chunk, modules);
33
+ }
34
+ }
35
+ });
36
+ });
37
+ }
38
+ /**
39
+ * Processes the modules in the chunk.
40
+ * @param {Compilation} compilation - The webpack compilation.
41
+ * @param {Chunk} chunk - The chunk to process.
42
+ * @param {Iterable<Module>} modules - The modules in the chunk.
43
+ */
44
+ processModules(compilation, chunk, modules) {
45
+ for (const module of modules) {
46
+ if (!compilation.chunkGraph.isModuleInChunk(module, chunk)) {
47
+ continue;
48
+ }
49
+ if (module.constructor.name === 'NormalModule') {
50
+ this.modulesToProcess.add(module);
51
+ }
52
+ }
53
+ this.removeModules(compilation, chunk);
54
+ }
55
+ /**
56
+ * Removes the modules from the chunk.
57
+ * @param {Compilation} compilation - The webpack compilation.
58
+ * @param {Chunk} chunk - The chunk to remove modules from.
59
+ */
60
+ removeModules(compilation, chunk) {
61
+ for (const moduleToRemove of this.modulesToProcess) {
62
+ if (this.debug) {
63
+ console.log('removing', moduleToRemove.constructor.name);
64
+ }
65
+ if (compilation.chunkGraph.isModuleInChunk(moduleToRemove, chunk)) {
66
+ compilation.chunkGraph.disconnectChunkAndModule(chunk, moduleToRemove);
67
+ }
68
+ }
69
+ }
70
+ }
71
+ exports.default = RemoveEagerModulesFromRuntimePlugin;
72
+ //# sourceMappingURL=RemoveEagerModulesFromRuntimePlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RemoveEagerModulesFromRuntimePlugin.js","sourceRoot":"","sources":["../../../../../../packages/nextjs-mf/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.ts"],"names":[],"mappings":";;AAEA;;;GAGG;AACH,MAAM,mCAAmC;IAKvC;;;;;OAKG;IACH,YAAY,OAAgD;QAC1D,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC;QACpC,IAAI,CAAC,gBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;IAC5C,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,QAAkB;QACtB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACnB,OAAO,CAAC,IAAI,CACV,cAAc,EACd,+DAA+D,EAC/D,IAAI,CAAC,SAAS,CACf,CAAC;YACF,OAAO;SACR;QAED,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,GAAG,CAChC,qCAAqC,EACrC,CAAC,WAAwB,EAAE,EAAE;YAC3B,WAAW,CAAC,KAAK,CAAC,oBAAoB,CAAC,GAAG,CACxC,qCAAqC,EACrC,CAAC,MAAuB,EAAE,OAAyB,EAAE,EAAE;gBACrD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;oBAC1B,IAAI,KAAK,CAAC,UAAU,EAAE,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,SAAS,EAAE;wBACvD,IAAI,CAAC,cAAc,CAAC,WAAW,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;qBAClD;iBACF;YACH,CAAC,CACF,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACK,cAAc,CACpB,WAAwB,EACxB,KAAY,EACZ,OAAyB;QAEzB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;YAC5B,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,eAAe,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE;gBAC1D,SAAS;aACV;YAED,IAAI,MAAM,CAAC,WAAW,CAAC,IAAI,KAAK,cAAc,EAAE;gBAC9C,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;aACnC;SACF;QAED,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IACzC,CAAC;IAED;;;;OAIG;IACK,aAAa,CAAC,WAAwB,EAAE,KAAY;QAC1D,KAAK,MAAM,cAAc,IAAI,IAAI,CAAC,gBAAgB,EAAE;YAClD,IAAI,IAAI,CAAC,KAAK,EAAE;gBACd,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;aAC1D;YAED,IAAI,WAAW,CAAC,UAAU,CAAC,eAAe,CAAC,cAAc,EAAE,KAAK,CAAC,EAAE;gBACjE,WAAW,CAAC,UAAU,CAAC,wBAAwB,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;aACxE;SACF;IACH,CAAC;CACF;AAED,kBAAe,mCAAmC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { FederationRuntimePlugin } from '@module-federation/runtime/type';
2
+ export default function (): FederationRuntimePlugin;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function default_1() {
4
+ return {
5
+ name: 'next-internal-plugin',
6
+ beforeInit(args) {
7
+ if (!__webpack_runtime_id__.startsWith('webpack'))
8
+ return args;
9
+ const attach =
10
+ //@ts-ignore
11
+ typeof __webpack_require__?.federation?.attachRemote === 'function'
12
+ ? //@ts-ignore
13
+ __webpack_require__.federation.attachRemote
14
+ : () => {
15
+ //@ts-ignore
16
+ console.error('embedded container', args.id, 'is not found');
17
+ return false;
18
+ };
19
+ const { moduleCache, name } = args.origin;
20
+ const attachedRemote = attach();
21
+ if (attachedRemote) {
22
+ moduleCache.set(name, attachedRemote);
23
+ }
24
+ return args;
25
+ },
26
+ init(args) {
27
+ return args;
28
+ },
29
+ beforeLoadRemote(args) {
30
+ return args;
31
+ },
32
+ // createScript(args) {
33
+ // return args;
34
+ // },
35
+ loadRemoteMatch(args) {
36
+ return args;
37
+ },
38
+ loadRemote(args) {
39
+ return args;
40
+ },
41
+ resolveShare(args) {
42
+ if (args.pkgName !== 'react' &&
43
+ args.pkgName !== 'react-dom' &&
44
+ !args.pkgName.startsWith('next/')) {
45
+ return args;
46
+ }
47
+ const { shareScopeMap, scope, pkgName, version, GlobalFederation } = args;
48
+ const host = GlobalFederation['__INSTANCES__'][0];
49
+ if (!host) {
50
+ return args;
51
+ }
52
+ args.resolver = function () {
53
+ shareScopeMap[scope][pkgName][version] = host.options.shared[pkgName]; // replace local share scope manually with desired module
54
+ return shareScopeMap[scope][pkgName][version];
55
+ };
56
+ return args;
57
+ },
58
+ async beforeLoadShare(args) {
59
+ return args;
60
+ },
61
+ };
62
+ }
63
+ exports.default = default_1;
64
+ //# sourceMappingURL=runtimePlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimePlugin.js","sourceRoot":"","sources":["../../../../../../packages/nextjs-mf/src/plugins/container/runtimePlugin.ts"],"names":[],"mappings":";;AAGA;IACE,OAAO;QACL,IAAI,EAAE,sBAAsB;QAC5B,UAAU,CAAC,IAAI;YACb,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC,SAAS,CAAC;gBAAE,OAAO,IAAI,CAAC;YAC/D,MAAM,MAAM;YACV,YAAY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C;aACb;YACD,IAAI,CAAC,QAAQ,GAAG;gBACd,aAAa,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,yDAAyD;gBAChI,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC;YAChD,CAAC,CAAC;YACF,OAAO,IAAI,CAAC;QACd,CAAC;QACD,KAAK,CAAC,eAAe,CAAC,IAAI;YACxB,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC;AAhED,4BAgEC"}
@@ -0,0 +1,2 @@
1
+ import type { container } from 'webpack';
2
+ export type ModuleFederationPluginOptions = ConstructorParameters<typeof container.ModuleFederationPlugin>['0'];
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../packages/nextjs-mf/src/plugins/container/types.ts"],"names":[],"mappings":""}
package/src/types.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ export declare interface WatchOptions {
2
+ /**
3
+ * Delay the rebuilt after the first change. Value is a time in ms.
4
+ */
5
+ aggregateTimeout?: number;
6
+ /**
7
+ * Resolve symlinks and watch symlink and real file. This is usually not needed as webpack already resolves symlinks ('resolve.symlinks').
8
+ */
9
+ followSymlinks?: boolean;
10
+ /**
11
+ * Ignore some files from watching (glob pattern or regexp).
12
+ */
13
+ ignored?: string | RegExp | string[];
14
+ /**
15
+ * Enable polling mode for watching.
16
+ */
17
+ poll?: number | boolean;
18
+ /**
19
+ * Stop watching when stdin stream has ended.
20
+ */
21
+ stdin?: boolean;
22
+ }
23
+ export declare interface CallbackFunction<T> {
24
+ (err?: null | Error, result?: T): any;
25
+ }
26
+ declare global {
27
+ var usedChunks: Set<string>;
28
+ }
package/src/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map