@module-federation/sdk 0.2.3 → 0.2.4

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.
@@ -8,23 +8,20 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
8
8
 
9
9
  var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
10
10
 
11
- function getWebpackPath(compiler) {
12
- var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
13
- framework: 'other'
14
- };
11
+ function getWebpackPath(compiler, options = {
12
+ framework: 'other'
13
+ }) {
15
14
  try {
16
15
  // @ts-ignore just throw err
17
16
  compiler.webpack();
18
17
  return '';
19
18
  } catch (err) {
20
19
  var _err_stack;
21
- var trace = ((_err_stack = err.stack) === null || _err_stack === void 0 ? void 0 : _err_stack.split('\n')) || [];
22
- var webpackErrLocation = trace.find(function(item) {
23
- return item.includes('at webpack');
24
- }) || '';
25
- var webpackLocationWithDetail = webpackErrLocation.replace(/[^\(\)]+/, '').slice(1, -1);
26
- var webpackPath = webpackLocationWithDetail.split(':').slice(0, -2).join(':');
27
- if ((options === null || options === void 0 ? void 0 : options.framework) === 'nextjs') {
20
+ const trace = ((_err_stack = err.stack) == null ? void 0 : _err_stack.split('\n')) || [];
21
+ const webpackErrLocation = trace.find((item)=>item.includes('at webpack')) || '';
22
+ const webpackLocationWithDetail = webpackErrLocation.replace(/[^\(\)]+/, '').slice(1, -1);
23
+ const webpackPath = webpackLocationWithDetail.split(':').slice(0, -2).join(':');
24
+ if ((options == null ? void 0 : options.framework) === 'nextjs') {
28
25
  if (webpackPath.endsWith('webpack.js')) {
29
26
  return webpackPath.replace('webpack.js', 'index.js');
30
27
  }
@@ -37,7 +34,7 @@ function getWebpackPath(compiler) {
37
34
  });
38
35
  }
39
36
  }
40
- var normalizeWebpackPath = function(fullPath) {
37
+ const normalizeWebpackPath = (fullPath)=>{
41
38
  if (fullPath === 'webpack') {
42
39
  return process.env['FEDERATION_WEBPACK_PATH'] || fullPath;
43
40
  }
@@ -1,22 +1,19 @@
1
1
  import path from 'path';
2
2
 
3
- function getWebpackPath(compiler) {
4
- var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
5
- framework: 'other'
6
- };
3
+ function getWebpackPath(compiler, options = {
4
+ framework: 'other'
5
+ }) {
7
6
  try {
8
7
  // @ts-ignore just throw err
9
8
  compiler.webpack();
10
9
  return '';
11
10
  } catch (err) {
12
11
  var _err_stack;
13
- var trace = ((_err_stack = err.stack) === null || _err_stack === void 0 ? void 0 : _err_stack.split('\n')) || [];
14
- var webpackErrLocation = trace.find(function(item) {
15
- return item.includes('at webpack');
16
- }) || '';
17
- var webpackLocationWithDetail = webpackErrLocation.replace(/[^\(\)]+/, '').slice(1, -1);
18
- var webpackPath = webpackLocationWithDetail.split(':').slice(0, -2).join(':');
19
- if ((options === null || options === void 0 ? void 0 : options.framework) === 'nextjs') {
12
+ const trace = ((_err_stack = err.stack) == null ? void 0 : _err_stack.split('\n')) || [];
13
+ const webpackErrLocation = trace.find((item)=>item.includes('at webpack')) || '';
14
+ const webpackLocationWithDetail = webpackErrLocation.replace(/[^\(\)]+/, '').slice(1, -1);
15
+ const webpackPath = webpackLocationWithDetail.split(':').slice(0, -2).join(':');
16
+ if ((options == null ? void 0 : options.framework) === 'nextjs') {
20
17
  if (webpackPath.endsWith('webpack.js')) {
21
18
  return webpackPath.replace('webpack.js', 'index.js');
22
19
  }
@@ -29,7 +26,7 @@ function getWebpackPath(compiler) {
29
26
  });
30
27
  }
31
28
  }
32
- var normalizeWebpackPath = function(fullPath) {
29
+ const normalizeWebpackPath = (fullPath)=>{
33
30
  if (fullPath === 'webpack') {
34
31
  return process.env['FEDERATION_WEBPACK_PATH'] || fullPath;
35
32
  }
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/sdk",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "license": "MIT",
5
5
  "description": "A sdk for support module federation",
6
6
  "keywords": [
package/dist/src/dom.d.ts CHANGED
@@ -9,7 +9,7 @@ export declare function createScript(info: {
9
9
  cb?: (value: void | PromiseLike<void>) => void;
10
10
  attrs?: Record<string, any>;
11
11
  needDeleteScript?: boolean;
12
- createScriptHook?: (url: string) => CreateScriptHookReturn;
12
+ createScriptHook?: (url: string, attrs?: Record<string, any> | undefined) => CreateScriptHookReturn;
13
13
  }): {
14
14
  script: HTMLScriptElement;
15
15
  needAttach: boolean;
@@ -26,5 +26,5 @@ export declare function createLink(info: {
26
26
  };
27
27
  export declare function loadScript(url: string, info: {
28
28
  attrs?: Record<string, any>;
29
- createScriptHook?: (url: string) => CreateScriptHookReturn;
29
+ createScriptHook?: (url: string, attrs?: Record<string, any> | undefined) => CreateScriptHookReturn;
30
30
  }): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/sdk",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "license": "MIT",
5
5
  "description": "A sdk for support module federation",
6
6
  "keywords": [