@module-federation/data-prefetch 0.0.0-next-20240927195332 → 0.0.0-next-20240930091801
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/CHANGELOG.md +4 -3
- package/LICENSE +1 -1
- package/dist/{src/cli → cli}/babel.d.ts +4 -2
- package/dist/cli/babel.js +84 -0
- package/dist/{src/cli → cli}/index.d.ts +8 -5
- package/dist/cli/index.js +207 -0
- package/dist/esm/chunk-AJPO2B2T.js +30 -0
- package/dist/esm/chunk-BGNOVRH5.js +166 -0
- package/dist/esm/chunk-EZUCZHGV.js +11 -0
- package/dist/esm/chunk-ISF7VMBW.js +156 -0
- package/dist/esm/chunk-OCDMSRMZ.js +32 -0
- package/dist/esm/chunk-TTJJJ2WZ.js +7 -0
- package/dist/esm/cli/babel.js +57 -0
- package/dist/esm/cli/index.js +180 -0
- package/dist/esm/index.js +13 -0
- package/dist/esm/plugin.js +12 -0
- package/dist/esm/react/index.js +94 -0
- package/dist/esm/shared/index.js +27 -0
- package/dist/esm/universal/index.js +9 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +351 -0
- package/dist/plugin.d.ts +5 -0
- package/dist/plugin.js +347 -0
- package/dist/{src/prefetch.d.ts → prefetch-c08be471.d.ts} +6 -4
- package/dist/react/index.d.ts +16 -0
- package/dist/react/index.js +287 -0
- package/dist/shared/index.d.ts +5 -0
- package/dist/shared/index.js +48 -0
- package/dist/universal/index.d.ts +8 -0
- package/dist/universal/index.js +205 -0
- package/package.json +28 -31
- package/project.json +4 -46
- package/src/cli/index.ts +2 -2
- package/tsconfig.json +1 -1
- package/dist/LICENSE +0 -21
- package/dist/babel.cjs.d.ts +0 -2
- package/dist/babel.cjs.js +0 -62
- package/dist/babel.esm.js +0 -56
- package/dist/cli.cjs.d.ts +0 -1
- package/dist/cli.cjs.js +0 -3579
- package/dist/cli.esm.js +0 -3565
- package/dist/index.cjs.d.ts +0 -1
- package/dist/index.cjs.js +0 -15
- package/dist/index.cjs2.js +0 -7
- package/dist/index.esm.js +0 -6
- package/dist/index.esm2.js +0 -5
- package/dist/package.json +0 -99
- package/dist/plugin.cjs.d.ts +0 -2
- package/dist/plugin.cjs.js +0 -362
- package/dist/plugin.esm.js +0 -357
- package/dist/prefetch.cjs.js +0 -351
- package/dist/prefetch.esm.js +0 -349
- package/dist/react.cjs.d.ts +0 -1
- package/dist/react.cjs.js +0 -163
- package/dist/react.esm.js +0 -159
- package/dist/runtime-utils.cjs.js +0 -31
- package/dist/runtime-utils.esm.js +0 -26
- package/dist/shared.cjs.d.ts +0 -2
- package/dist/shared.cjs.js +0 -26
- package/dist/shared.esm.js +0 -24
- package/dist/src/common/constant.d.ts +0 -1
- package/dist/src/common/index.d.ts +0 -1
- package/dist/src/common/node-utils.d.ts +0 -2
- package/dist/src/common/runtime-utils.d.ts +0 -5
- package/dist/src/index.d.ts +0 -2
- package/dist/src/logger/index.d.ts +0 -3
- package/dist/src/plugin.d.ts +0 -3
- package/dist/src/react/hooks.d.ts +0 -11
- package/dist/src/react/index.d.ts +0 -1
- package/dist/src/react/utils.d.ts +0 -1
- package/dist/src/shared/index.d.ts +0 -3
- package/dist/src/universal/index.d.ts +0 -2
- package/dist/universal.cjs.d.ts +0 -1
- package/dist/universal.cjs.js +0 -38
- package/dist/universal.esm.js +0 -34
- package/rollup.config.js +0 -25
- package/tsconfig.lib.json +0 -10
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/data-prefetch",
|
|
3
3
|
"description": "Module Federation Data Prefetch",
|
|
4
|
-
"version": "0.0.0-next-
|
|
4
|
+
"version": "0.0.0-next-20240930091801",
|
|
5
5
|
"author": "nieyan <nyqykk@foxmail.com>",
|
|
6
6
|
"homepage": "https://github.com/module-federation/core",
|
|
7
7
|
"license": "MIT",
|
|
@@ -10,60 +10,57 @@
|
|
|
10
10
|
},
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
-
"import": "./dist/index.
|
|
14
|
-
"require": "./dist/index.
|
|
15
|
-
"types": "./dist/index.
|
|
13
|
+
"import": "./dist/esm/index.js",
|
|
14
|
+
"require": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts"
|
|
16
16
|
},
|
|
17
17
|
"./react": {
|
|
18
|
-
"import": "./dist/react.
|
|
19
|
-
"require": "./dist/react.
|
|
20
|
-
"types": "./dist/react.
|
|
18
|
+
"import": "./dist/esm/react/index.js",
|
|
19
|
+
"require": "./dist/react/index.js",
|
|
20
|
+
"types": "./dist/react/index.d.ts"
|
|
21
21
|
},
|
|
22
22
|
"./cli": {
|
|
23
|
-
"import": "./dist/cli.
|
|
24
|
-
"require": "./dist/cli.
|
|
25
|
-
"types": "./dist/cli.
|
|
23
|
+
"import": "./dist/esm/cli/index.js",
|
|
24
|
+
"require": "./dist/cli/index.js",
|
|
25
|
+
"types": "./dist/cli/index.d.ts"
|
|
26
26
|
},
|
|
27
27
|
"./babel-plugin": {
|
|
28
|
-
"import": "./dist/babel.
|
|
29
|
-
"require": "./dist/babel.
|
|
30
|
-
"types": "./dist/babel.
|
|
28
|
+
"import": "./dist/esm/cli/babel.js",
|
|
29
|
+
"require": "./dist/cli/babel.js",
|
|
30
|
+
"types": "./dist/cli/babel.d.ts"
|
|
31
31
|
},
|
|
32
32
|
"./universal": {
|
|
33
|
-
"import": "./dist/universal.
|
|
34
|
-
"require": "./dist/universal.
|
|
35
|
-
"types": "./dist/universal.
|
|
33
|
+
"import": "./dist/esm/universal/index.js",
|
|
34
|
+
"require": "./dist/universal/index.js",
|
|
35
|
+
"types": "./dist/universal/index.d.ts"
|
|
36
36
|
},
|
|
37
37
|
"./shared": {
|
|
38
|
-
"import": "./dist/shared.
|
|
39
|
-
"require": "./dist/shared.
|
|
40
|
-
"types": "./dist/shared
|
|
38
|
+
"import": "./dist/esm/shared/index.js",
|
|
39
|
+
"require": "./dist/shared/index.js",
|
|
40
|
+
"types": "./dist/shared/index.d.ts"
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
"typesVersions": {
|
|
44
44
|
"*": {
|
|
45
45
|
".": [
|
|
46
|
-
"./dist/index.
|
|
46
|
+
"./dist/index.d.ts"
|
|
47
47
|
],
|
|
48
48
|
"react": [
|
|
49
|
-
"./dist/react.
|
|
49
|
+
"./dist/react/index.d.ts"
|
|
50
50
|
],
|
|
51
51
|
"cli": [
|
|
52
|
-
"./dist/cli.
|
|
52
|
+
"./dist/cli/index.d.ts"
|
|
53
53
|
],
|
|
54
54
|
"universal": [
|
|
55
|
-
"./dist/universal.
|
|
55
|
+
"./dist/universal/index.d.ts"
|
|
56
56
|
],
|
|
57
57
|
"shared": [
|
|
58
|
-
"./dist/shared.
|
|
59
|
-
],
|
|
60
|
-
"babel-plugin": [
|
|
61
|
-
"./dist/babel.cjs.d.ts"
|
|
58
|
+
"./dist/shared/index.d.ts"
|
|
62
59
|
]
|
|
63
60
|
}
|
|
64
61
|
},
|
|
65
|
-
"main": "dist/index.
|
|
66
|
-
"module": "dist/index.
|
|
62
|
+
"main": "dist/index.js",
|
|
63
|
+
"module": "dist/esm/index.js",
|
|
67
64
|
"peerDependencies": {
|
|
68
65
|
"react": ">=16.9.0",
|
|
69
66
|
"react-dom": ">=16.9.0"
|
|
@@ -88,8 +85,8 @@
|
|
|
88
85
|
},
|
|
89
86
|
"dependencies": {
|
|
90
87
|
"fs-extra": "9.1.0",
|
|
91
|
-
"@module-federation/sdk": "0.0.0-next-
|
|
92
|
-
"@module-federation/runtime": "0.0.0-next-
|
|
88
|
+
"@module-federation/sdk": "0.0.0-next-20240930091801",
|
|
89
|
+
"@module-federation/runtime": "0.0.0-next-20240930091801"
|
|
93
90
|
},
|
|
94
91
|
"scripts": {
|
|
95
92
|
"dev": "cross-env WATCH=true tsup",
|
package/project.json
CHANGED
|
@@ -1,61 +1,19 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "data-prefetch",
|
|
2
|
+
"name": "module-federation/data-prefetch",
|
|
3
3
|
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
4
|
"sourceRoot": "packages/data-prefetch/src",
|
|
5
5
|
"projectType": "library",
|
|
6
6
|
"targets": {
|
|
7
7
|
"build": {
|
|
8
|
-
"executor": "
|
|
9
|
-
"outputs": ["{options.outputPath}"],
|
|
8
|
+
"executor": "nx:run-commands",
|
|
10
9
|
"options": {
|
|
11
|
-
"
|
|
12
|
-
"main": "packages/data-prefetch/src/index.ts",
|
|
13
|
-
"tsConfig": "packages/data-prefetch/tsconfig.lib.json",
|
|
14
|
-
"assets": [],
|
|
15
|
-
"project": "packages/data-prefetch/package.json",
|
|
16
|
-
"rollupConfig": "packages/data-prefetch/rollup.config.js",
|
|
17
|
-
"compiler": "swc",
|
|
18
|
-
"format": ["cjs", "esm"]
|
|
10
|
+
"commands": ["npm run build --prefix packages/data-prefetch"]
|
|
19
11
|
}
|
|
20
12
|
},
|
|
21
13
|
"test": {
|
|
22
|
-
"executor": "@nx/jest:jest",
|
|
23
|
-
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
|
24
|
-
"options": {
|
|
25
|
-
"jestConfig": "packages/data-prefetch/jest.config.js",
|
|
26
|
-
"passWithNoTests": true
|
|
27
|
-
},
|
|
28
|
-
"configurations": {
|
|
29
|
-
"ci": {
|
|
30
|
-
"ci": true,
|
|
31
|
-
"codeCoverage": true
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
"lint": {
|
|
36
|
-
"executor": "@nx/linter:eslint",
|
|
37
|
-
"outputs": ["{options.outputFile}"],
|
|
38
|
-
"options": {
|
|
39
|
-
"lintFilePatterns": [
|
|
40
|
-
"packages/data-prefetch/**/*.ts",
|
|
41
|
-
"packages/data-prefetch/package.json"
|
|
42
|
-
]
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
"pre-release": {
|
|
46
14
|
"executor": "nx:run-commands",
|
|
47
15
|
"options": {
|
|
48
|
-
"
|
|
49
|
-
"commands": [
|
|
50
|
-
{
|
|
51
|
-
"command": "nx run data-prefetch:test",
|
|
52
|
-
"forwardAllArgs": false
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
"command": "nx run data-prefetch:build",
|
|
56
|
-
"forwardAllArgs": false
|
|
57
|
-
}
|
|
58
|
-
]
|
|
16
|
+
"commands": ["npm run test --prefix packages/data-prefetch"]
|
|
59
17
|
}
|
|
60
18
|
}
|
|
61
19
|
},
|
package/src/cli/index.ts
CHANGED
|
@@ -47,8 +47,8 @@ export class PrefetchPlugin implements WebpackPluginInstance {
|
|
|
47
47
|
this.options.runtimePlugins = [];
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
const runtimePath = path.resolve(__dirname, '
|
|
51
|
-
const sharedPath = path.resolve(__dirname, '
|
|
50
|
+
const runtimePath = path.resolve(__dirname, '../esm/plugin.js');
|
|
51
|
+
const sharedPath = path.resolve(__dirname, '../esm/shared/index.js');
|
|
52
52
|
if (!this.options.runtimePlugins?.includes(runtimePath)) {
|
|
53
53
|
this.options.runtimePlugins!.push(runtimePath);
|
|
54
54
|
}
|
package/tsconfig.json
CHANGED
package/dist/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024-present nieyan(nyqykk)
|
|
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/dist/babel.cjs.d.ts
DELETED
package/dist/babel.cjs.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var require$$1 = require('path');
|
|
4
|
-
|
|
5
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
6
|
-
|
|
7
|
-
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
|
|
8
|
-
|
|
9
|
-
// no used now
|
|
10
|
-
var attribute = 'id';
|
|
11
|
-
var hookId = 'usePrefetch';
|
|
12
|
-
var importPackage = '@module-federation/data-prefetch/react';
|
|
13
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
14
|
-
function babel(babel, options) {
|
|
15
|
-
var t = babel.types;
|
|
16
|
-
var shouldHandle = false;
|
|
17
|
-
var scope = '';
|
|
18
|
-
var name = options.name, exposes = options.exposes;
|
|
19
|
-
if (!exposes) {
|
|
20
|
-
return {};
|
|
21
|
-
}
|
|
22
|
-
var exposesKey = Object.keys(exposes);
|
|
23
|
-
var processedExposes = exposesKey.map(function(expose) {
|
|
24
|
-
return {
|
|
25
|
-
key: expose.replace('.', ''),
|
|
26
|
-
value: require$$1__default["default"].resolve(// @ts-ignore
|
|
27
|
-
typeof exposes[expose] === 'string' ? exposes[expose] : exposes[expose].import)
|
|
28
|
-
};
|
|
29
|
-
});
|
|
30
|
-
return {
|
|
31
|
-
visitor: {
|
|
32
|
-
ImportDeclaration: function ImportDeclaration(nodePath, // biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
33
|
-
state) {
|
|
34
|
-
var source = nodePath.node.source.value;
|
|
35
|
-
var specifiers = nodePath.node.specifiers;
|
|
36
|
-
var filename = state.file.opts.filename;
|
|
37
|
-
if (source === importPackage) {
|
|
38
|
-
shouldHandle = specifiers.some(function(specifier) {
|
|
39
|
-
return specifier.imported && specifier.imported.name === hookId && processedExposes.find(// biome-ignore lint/suspicious/noAssignInExpressions: <explanation>
|
|
40
|
-
function(expose) {
|
|
41
|
-
return expose.value === filename && (scope = expose.key);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
CallExpression: function CallExpression(nodePath) {
|
|
47
|
-
if (shouldHandle && t.isIdentifier(nodePath.node.callee, {
|
|
48
|
-
name: hookId
|
|
49
|
-
}) && nodePath.node.arguments.length > 0) {
|
|
50
|
-
var objectExpression = nodePath.node.arguments[0];
|
|
51
|
-
if (objectExpression && t.isObjectExpression(objectExpression) && !objectExpression.properties.find(function(p) {
|
|
52
|
-
return p.key.name === attribute;
|
|
53
|
-
})) {
|
|
54
|
-
objectExpression.properties.push(t.objectProperty(t.identifier(attribute), t.stringLiteral(name + scope)));
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
module.exports = babel;
|
package/dist/babel.esm.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import require$$1 from 'path';
|
|
2
|
-
|
|
3
|
-
// no used now
|
|
4
|
-
var attribute = 'id';
|
|
5
|
-
var hookId = 'usePrefetch';
|
|
6
|
-
var importPackage = '@module-federation/data-prefetch/react';
|
|
7
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
8
|
-
function babel(babel, options) {
|
|
9
|
-
var t = babel.types;
|
|
10
|
-
var shouldHandle = false;
|
|
11
|
-
var scope = '';
|
|
12
|
-
var name = options.name, exposes = options.exposes;
|
|
13
|
-
if (!exposes) {
|
|
14
|
-
return {};
|
|
15
|
-
}
|
|
16
|
-
var exposesKey = Object.keys(exposes);
|
|
17
|
-
var processedExposes = exposesKey.map(function(expose) {
|
|
18
|
-
return {
|
|
19
|
-
key: expose.replace('.', ''),
|
|
20
|
-
value: require$$1.resolve(// @ts-ignore
|
|
21
|
-
typeof exposes[expose] === 'string' ? exposes[expose] : exposes[expose].import)
|
|
22
|
-
};
|
|
23
|
-
});
|
|
24
|
-
return {
|
|
25
|
-
visitor: {
|
|
26
|
-
ImportDeclaration: function ImportDeclaration(nodePath, // biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
27
|
-
state) {
|
|
28
|
-
var source = nodePath.node.source.value;
|
|
29
|
-
var specifiers = nodePath.node.specifiers;
|
|
30
|
-
var filename = state.file.opts.filename;
|
|
31
|
-
if (source === importPackage) {
|
|
32
|
-
shouldHandle = specifiers.some(function(specifier) {
|
|
33
|
-
return specifier.imported && specifier.imported.name === hookId && processedExposes.find(// biome-ignore lint/suspicious/noAssignInExpressions: <explanation>
|
|
34
|
-
function(expose) {
|
|
35
|
-
return expose.value === filename && (scope = expose.key);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
CallExpression: function CallExpression(nodePath) {
|
|
41
|
-
if (shouldHandle && t.isIdentifier(nodePath.node.callee, {
|
|
42
|
-
name: hookId
|
|
43
|
-
}) && nodePath.node.arguments.length > 0) {
|
|
44
|
-
var objectExpression = nodePath.node.arguments[0];
|
|
45
|
-
if (objectExpression && t.isObjectExpression(objectExpression) && !objectExpression.properties.find(function(p) {
|
|
46
|
-
return p.key.name === attribute;
|
|
47
|
-
})) {
|
|
48
|
-
objectExpression.properties.push(t.objectProperty(t.identifier(attribute), t.stringLiteral(name + scope)));
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export { babel as default };
|
package/dist/cli.cjs.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./src/cli/index";
|