@dcoder-x/next 0.1.7 → 0.1.8
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/dist/ClippyWebpackPlugin.js +13 -3
- package/package.json +2 -2
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.ClippyWebpackPlugin = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
4
8
|
const RouteExtractor_1 = require("@dcoder-x/plugin-shared/extractors/RouteExtractor");
|
|
5
9
|
const ComponentExtractor_1 = require("@dcoder-x/plugin-shared/extractors/ComponentExtractor");
|
|
6
10
|
const SelectorGenerator_1 = require("@dcoder-x/plugin-shared/extractors/SelectorGenerator");
|
|
@@ -9,6 +13,10 @@ const PackageBuilder_1 = require("@dcoder-x/plugin-shared/upload/PackageBuilder"
|
|
|
9
13
|
const PackageWriter_1 = require("@dcoder-x/plugin-shared/upload/PackageWriter");
|
|
10
14
|
const Uploader_1 = require("@dcoder-x/plugin-shared/upload/Uploader");
|
|
11
15
|
const plugin_shared_1 = require("@dcoder-x/plugin-shared");
|
|
16
|
+
/** Convert any absolute or backslash path to a forward-slash path relative to cwd. */
|
|
17
|
+
function toRelKey(absPath, dir) {
|
|
18
|
+
return path_1.default.relative(dir, absPath).replace(/\\/g, '/');
|
|
19
|
+
}
|
|
12
20
|
class ClippyWebpackPlugin {
|
|
13
21
|
constructor(options, context) {
|
|
14
22
|
this.options = options;
|
|
@@ -23,18 +31,20 @@ class ClippyWebpackPlugin {
|
|
|
23
31
|
const extractor = new ComponentExtractor_1.ComponentExtractor({ type: 'webpack', compilation }, routes);
|
|
24
32
|
const elements = await extractor.extract();
|
|
25
33
|
const components = await extractor.extractComponents();
|
|
26
|
-
// Collect injected metadata attached by the loader (if any)
|
|
34
|
+
// Collect injected metadata attached by the loader (if any).
|
|
35
|
+
// Keys are normalised to relative forward-slash paths so they match
|
|
36
|
+
// the filePath values stored on DiscoveredElement by ComponentExtractor.
|
|
27
37
|
const injectedMap = {};
|
|
28
38
|
try {
|
|
29
39
|
const modules = compilation.modules || [];
|
|
30
40
|
for (const mod of modules) {
|
|
31
41
|
try {
|
|
32
42
|
const resource = mod.resource || mod.userRequest || (mod.identifier && mod.identifier());
|
|
33
|
-
if (!resource)
|
|
43
|
+
if (!resource || resource.includes('node_modules'))
|
|
34
44
|
continue;
|
|
35
45
|
const meta = mod.__clippy_injected || mod.buildInfo?.__clippy_injected || (mod._module && mod._module.__clippy_injected);
|
|
36
46
|
if (meta && Array.isArray(meta) && meta.length) {
|
|
37
|
-
injectedMap[resource] = meta;
|
|
47
|
+
injectedMap[toRelKey(resource, this.context.dir)] = meta;
|
|
38
48
|
}
|
|
39
49
|
}
|
|
40
50
|
catch { }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcoder-x/next",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@dcoder-x/plugin-shared": "^0.1.
|
|
13
|
+
"@dcoder-x/plugin-shared": "^0.1.11"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"next": ">=13.0.0",
|