@loupfeed/webpack-plugin 0.1.0
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/LICENSE.md +114 -0
- package/dist/chunk-EN5B3LN6.js +16 -0
- package/dist/chunk-EN5B3LN6.js.map +1 -0
- package/dist/index.cjs +67 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +36 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/loader.cjs +47 -0
- package/dist/loader.cjs.map +1 -0
- package/dist/loader.d.cts +15 -0
- package/dist/loader.d.ts +15 -0
- package/dist/loader.js +16 -0
- package/dist/loader.js.map +1 -0
- package/package.json +51 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Functional Source License, Version 1.1, Apache 2.0 Future License
|
|
2
|
+
|
|
3
|
+
## Abbreviation
|
|
4
|
+
|
|
5
|
+
FSL-1.1-ALv2
|
|
6
|
+
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 loupfeed
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to use,
|
|
27
|
+
copy, modify, create derivative works, publicly perform, publicly display and
|
|
28
|
+
redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or service
|
|
34
|
+
that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software that
|
|
39
|
+
exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee using
|
|
52
|
+
the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to the
|
|
59
|
+
infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software, you
|
|
68
|
+
must include a copy of or a link to these Terms and Conditions and not remove any
|
|
69
|
+
copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, INCLUDING
|
|
74
|
+
BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, NON-INFRINGEMENT AND TITLE.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, EVEN
|
|
79
|
+
IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of the
|
|
84
|
+
Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following will
|
|
93
|
+
apply:
|
|
94
|
+
|
|
95
|
+
We hereby grant you a license to the Software under the Apache License, Version
|
|
96
|
+
2.0, a copy of which is available at https://www.apache.org/licenses/LICENSE-2.0.
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## In plain language (non-binding summary)
|
|
101
|
+
|
|
102
|
+
This is a **Fair Source** license. You can:
|
|
103
|
+
|
|
104
|
+
- **Self-host and run loupfeed** for your own purposes — including inside a
|
|
105
|
+
company, on your own servers or cloud account, for your own products.
|
|
106
|
+
- Read, modify, fork, and redistribute the source.
|
|
107
|
+
|
|
108
|
+
The one thing you may **not** do is offer loupfeed (or something substantially
|
|
109
|
+
similar built from it) **as a competing commercial product or hosted service**.
|
|
110
|
+
|
|
111
|
+
Two years after each release is published, that version automatically becomes
|
|
112
|
+
available to you under the **Apache License 2.0** (fully open source).
|
|
113
|
+
|
|
114
|
+
This summary is for convenience only; the Terms and Conditions above govern.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/registry.ts
|
|
2
|
+
import { createTagger } from "@loupfeed/build";
|
|
3
|
+
var taggers = /* @__PURE__ */ new Map();
|
|
4
|
+
function getTagger(projectRoot, include) {
|
|
5
|
+
let tagger = taggers.get(projectRoot);
|
|
6
|
+
if (!tagger) {
|
|
7
|
+
tagger = createTagger({ projectRoot, include });
|
|
8
|
+
taggers.set(projectRoot, tagger);
|
|
9
|
+
}
|
|
10
|
+
return tagger;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
getTagger
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=chunk-EN5B3LN6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/registry.ts"],"sourcesContent":["import { createTagger, type Tagger } from '@loupfeed/build';\n\n/**\n * The loader and the plugin run in the same Node process but are separate\n * modules; they share the per-project tagger (and its accumulating manifest)\n * through this registry, keyed by project root.\n */\nconst taggers = new Map<string, Tagger>();\n\nexport function getTagger(projectRoot: string, include?: RegExp): Tagger {\n let tagger = taggers.get(projectRoot);\n if (!tagger) {\n tagger = createTagger({ projectRoot, include });\n taggers.set(projectRoot, tagger);\n }\n return tagger;\n}\n"],"mappings":";AAAA,SAAS,oBAAiC;AAO1C,IAAM,UAAU,oBAAI,IAAoB;AAEjC,SAAS,UAAU,aAAqB,SAA0B;AACvE,MAAI,SAAS,QAAQ,IAAI,WAAW;AACpC,MAAI,CAAC,QAAQ;AACX,aAAS,aAAa,EAAE,aAAa,QAAQ,CAAC;AAC9C,YAAQ,IAAI,aAAa,MAAM;AAAA,EACjC;AACA,SAAO;AACT;","names":[]}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
LoupfeedWebpackPlugin: () => LoupfeedWebpackPlugin,
|
|
24
|
+
getTagger: () => getTagger
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
var import_build2 = require("@loupfeed/build");
|
|
28
|
+
|
|
29
|
+
// src/registry.ts
|
|
30
|
+
var import_build = require("@loupfeed/build");
|
|
31
|
+
var taggers = /* @__PURE__ */ new Map();
|
|
32
|
+
function getTagger(projectRoot, include) {
|
|
33
|
+
let tagger = taggers.get(projectRoot);
|
|
34
|
+
if (!tagger) {
|
|
35
|
+
tagger = (0, import_build.createTagger)({ projectRoot, include });
|
|
36
|
+
taggers.set(projectRoot, tagger);
|
|
37
|
+
}
|
|
38
|
+
return tagger;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// src/index.ts
|
|
42
|
+
var LoupfeedWebpackPlugin = class {
|
|
43
|
+
constructor(options = {}) {
|
|
44
|
+
this.options = options;
|
|
45
|
+
}
|
|
46
|
+
apply(compiler) {
|
|
47
|
+
const projectRoot = this.options.projectRoot ?? compiler.options.context ?? process.cwd();
|
|
48
|
+
const release = this.options.release ?? (0, import_build2.buildIdentity)({ cwd: projectRoot }).release;
|
|
49
|
+
const tagger = getTagger(projectRoot, this.options.include);
|
|
50
|
+
compiler.hooks.afterEmit.tapPromise("LoupfeedWebpackPlugin", async () => {
|
|
51
|
+
const ids = tagger.manifest();
|
|
52
|
+
if (Object.keys(ids).length === 0) return;
|
|
53
|
+
if (this.options.writeManifest !== false) {
|
|
54
|
+
(0, import_build2.writeManifestFile)({ ids, release, outDir: this.options.manifestDir ?? projectRoot });
|
|
55
|
+
}
|
|
56
|
+
if (this.options.dsn && this.options.authToken) {
|
|
57
|
+
await (0, import_build2.uploadManifest)({ dsn: this.options.dsn, release, ids, authToken: this.options.authToken });
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
+
0 && (module.exports = {
|
|
64
|
+
LoupfeedWebpackPlugin,
|
|
65
|
+
getTagger
|
|
66
|
+
});
|
|
67
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/registry.ts"],"sourcesContent":["/**\n * @loupfeed/webpack-plugin — pairs with `@loupfeed/webpack-plugin/loader`.\n * The loader injects opaque ids; this plugin writes/uploads the server-side\n * manifest after emit. Minimal structural webpack types keep `webpack` a pure\n * peerDependency (no heavy build-time dep).\n */\n\nimport { buildIdentity, uploadManifest, writeManifestFile } from '@loupfeed/build';\nimport { getTagger } from './registry';\n\ninterface WebpackCompiler {\n hooks: { afterEmit: { tapPromise(name: string, cb: () => Promise<void>): void } };\n options: { context?: string };\n}\n\nexport interface LoupfeedWebpackOptions {\n dsn?: string;\n authToken?: string;\n release?: string;\n include?: RegExp;\n projectRoot?: string;\n writeManifest?: boolean;\n manifestDir?: string;\n}\n\nexport class LoupfeedWebpackPlugin {\n constructor(private readonly options: LoupfeedWebpackOptions = {}) {}\n\n apply(compiler: WebpackCompiler): void {\n const projectRoot = this.options.projectRoot ?? compiler.options.context ?? process.cwd();\n const release = this.options.release ?? buildIdentity({ cwd: projectRoot }).release;\n const tagger = getTagger(projectRoot, this.options.include);\n\n compiler.hooks.afterEmit.tapPromise('LoupfeedWebpackPlugin', async () => {\n const ids = tagger.manifest();\n if (Object.keys(ids).length === 0) return;\n if (this.options.writeManifest !== false) {\n writeManifestFile({ ids, release, outDir: this.options.manifestDir ?? projectRoot });\n }\n if (this.options.dsn && this.options.authToken) {\n await uploadManifest({ dsn: this.options.dsn, release, ids, authToken: this.options.authToken });\n }\n });\n }\n}\n\nexport { getTagger } from './registry';\n","import { createTagger, type Tagger } from '@loupfeed/build';\n\n/**\n * The loader and the plugin run in the same Node process but are separate\n * modules; they share the per-project tagger (and its accumulating manifest)\n * through this registry, keyed by project root.\n */\nconst taggers = new Map<string, Tagger>();\n\nexport function getTagger(projectRoot: string, include?: RegExp): Tagger {\n let tagger = taggers.get(projectRoot);\n if (!tagger) {\n tagger = createTagger({ projectRoot, include });\n taggers.set(projectRoot, tagger);\n }\n return tagger;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,IAAAA,gBAAiE;;;ACPjE,mBAA0C;AAO1C,IAAM,UAAU,oBAAI,IAAoB;AAEjC,SAAS,UAAU,aAAqB,SAA0B;AACvE,MAAI,SAAS,QAAQ,IAAI,WAAW;AACpC,MAAI,CAAC,QAAQ;AACX,iBAAS,2BAAa,EAAE,aAAa,QAAQ,CAAC;AAC9C,YAAQ,IAAI,aAAa,MAAM;AAAA,EACjC;AACA,SAAO;AACT;;;ADSO,IAAM,wBAAN,MAA4B;AAAA,EACjC,YAA6B,UAAkC,CAAC,GAAG;AAAtC;AAAA,EAAuC;AAAA,EAEpE,MAAM,UAAiC;AACrC,UAAM,cAAc,KAAK,QAAQ,eAAe,SAAS,QAAQ,WAAW,QAAQ,IAAI;AACxF,UAAM,UAAU,KAAK,QAAQ,eAAW,6BAAc,EAAE,KAAK,YAAY,CAAC,EAAE;AAC5E,UAAM,SAAS,UAAU,aAAa,KAAK,QAAQ,OAAO;AAE1D,aAAS,MAAM,UAAU,WAAW,yBAAyB,YAAY;AACvE,YAAM,MAAM,OAAO,SAAS;AAC5B,UAAI,OAAO,KAAK,GAAG,EAAE,WAAW,EAAG;AACnC,UAAI,KAAK,QAAQ,kBAAkB,OAAO;AACxC,6CAAkB,EAAE,KAAK,SAAS,QAAQ,KAAK,QAAQ,eAAe,YAAY,CAAC;AAAA,MACrF;AACA,UAAI,KAAK,QAAQ,OAAO,KAAK,QAAQ,WAAW;AAC9C,kBAAM,8BAAe,EAAE,KAAK,KAAK,QAAQ,KAAK,SAAS,KAAK,WAAW,KAAK,QAAQ,UAAU,CAAC;AAAA,MACjG;AAAA,IACF,CAAC;AAAA,EACH;AACF;","names":["import_build"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Tagger } from '@loupfeed/build';
|
|
2
|
+
|
|
3
|
+
declare function getTagger(projectRoot: string, include?: RegExp): Tagger;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @loupfeed/webpack-plugin — pairs with `@loupfeed/webpack-plugin/loader`.
|
|
7
|
+
* The loader injects opaque ids; this plugin writes/uploads the server-side
|
|
8
|
+
* manifest after emit. Minimal structural webpack types keep `webpack` a pure
|
|
9
|
+
* peerDependency (no heavy build-time dep).
|
|
10
|
+
*/
|
|
11
|
+
interface WebpackCompiler {
|
|
12
|
+
hooks: {
|
|
13
|
+
afterEmit: {
|
|
14
|
+
tapPromise(name: string, cb: () => Promise<void>): void;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
options: {
|
|
18
|
+
context?: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
interface LoupfeedWebpackOptions {
|
|
22
|
+
dsn?: string;
|
|
23
|
+
authToken?: string;
|
|
24
|
+
release?: string;
|
|
25
|
+
include?: RegExp;
|
|
26
|
+
projectRoot?: string;
|
|
27
|
+
writeManifest?: boolean;
|
|
28
|
+
manifestDir?: string;
|
|
29
|
+
}
|
|
30
|
+
declare class LoupfeedWebpackPlugin {
|
|
31
|
+
private readonly options;
|
|
32
|
+
constructor(options?: LoupfeedWebpackOptions);
|
|
33
|
+
apply(compiler: WebpackCompiler): void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { type LoupfeedWebpackOptions, LoupfeedWebpackPlugin, getTagger };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Tagger } from '@loupfeed/build';
|
|
2
|
+
|
|
3
|
+
declare function getTagger(projectRoot: string, include?: RegExp): Tagger;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @loupfeed/webpack-plugin — pairs with `@loupfeed/webpack-plugin/loader`.
|
|
7
|
+
* The loader injects opaque ids; this plugin writes/uploads the server-side
|
|
8
|
+
* manifest after emit. Minimal structural webpack types keep `webpack` a pure
|
|
9
|
+
* peerDependency (no heavy build-time dep).
|
|
10
|
+
*/
|
|
11
|
+
interface WebpackCompiler {
|
|
12
|
+
hooks: {
|
|
13
|
+
afterEmit: {
|
|
14
|
+
tapPromise(name: string, cb: () => Promise<void>): void;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
options: {
|
|
18
|
+
context?: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
interface LoupfeedWebpackOptions {
|
|
22
|
+
dsn?: string;
|
|
23
|
+
authToken?: string;
|
|
24
|
+
release?: string;
|
|
25
|
+
include?: RegExp;
|
|
26
|
+
projectRoot?: string;
|
|
27
|
+
writeManifest?: boolean;
|
|
28
|
+
manifestDir?: string;
|
|
29
|
+
}
|
|
30
|
+
declare class LoupfeedWebpackPlugin {
|
|
31
|
+
private readonly options;
|
|
32
|
+
constructor(options?: LoupfeedWebpackOptions);
|
|
33
|
+
apply(compiler: WebpackCompiler): void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { type LoupfeedWebpackOptions, LoupfeedWebpackPlugin, getTagger };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getTagger
|
|
3
|
+
} from "./chunk-EN5B3LN6.js";
|
|
4
|
+
|
|
5
|
+
// src/index.ts
|
|
6
|
+
import { buildIdentity, uploadManifest, writeManifestFile } from "@loupfeed/build";
|
|
7
|
+
var LoupfeedWebpackPlugin = class {
|
|
8
|
+
constructor(options = {}) {
|
|
9
|
+
this.options = options;
|
|
10
|
+
}
|
|
11
|
+
apply(compiler) {
|
|
12
|
+
const projectRoot = this.options.projectRoot ?? compiler.options.context ?? process.cwd();
|
|
13
|
+
const release = this.options.release ?? buildIdentity({ cwd: projectRoot }).release;
|
|
14
|
+
const tagger = getTagger(projectRoot, this.options.include);
|
|
15
|
+
compiler.hooks.afterEmit.tapPromise("LoupfeedWebpackPlugin", async () => {
|
|
16
|
+
const ids = tagger.manifest();
|
|
17
|
+
if (Object.keys(ids).length === 0) return;
|
|
18
|
+
if (this.options.writeManifest !== false) {
|
|
19
|
+
writeManifestFile({ ids, release, outDir: this.options.manifestDir ?? projectRoot });
|
|
20
|
+
}
|
|
21
|
+
if (this.options.dsn && this.options.authToken) {
|
|
22
|
+
await uploadManifest({ dsn: this.options.dsn, release, ids, authToken: this.options.authToken });
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
LoupfeedWebpackPlugin,
|
|
29
|
+
getTagger
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @loupfeed/webpack-plugin — pairs with `@loupfeed/webpack-plugin/loader`.\n * The loader injects opaque ids; this plugin writes/uploads the server-side\n * manifest after emit. Minimal structural webpack types keep `webpack` a pure\n * peerDependency (no heavy build-time dep).\n */\n\nimport { buildIdentity, uploadManifest, writeManifestFile } from '@loupfeed/build';\nimport { getTagger } from './registry';\n\ninterface WebpackCompiler {\n hooks: { afterEmit: { tapPromise(name: string, cb: () => Promise<void>): void } };\n options: { context?: string };\n}\n\nexport interface LoupfeedWebpackOptions {\n dsn?: string;\n authToken?: string;\n release?: string;\n include?: RegExp;\n projectRoot?: string;\n writeManifest?: boolean;\n manifestDir?: string;\n}\n\nexport class LoupfeedWebpackPlugin {\n constructor(private readonly options: LoupfeedWebpackOptions = {}) {}\n\n apply(compiler: WebpackCompiler): void {\n const projectRoot = this.options.projectRoot ?? compiler.options.context ?? process.cwd();\n const release = this.options.release ?? buildIdentity({ cwd: projectRoot }).release;\n const tagger = getTagger(projectRoot, this.options.include);\n\n compiler.hooks.afterEmit.tapPromise('LoupfeedWebpackPlugin', async () => {\n const ids = tagger.manifest();\n if (Object.keys(ids).length === 0) return;\n if (this.options.writeManifest !== false) {\n writeManifestFile({ ids, release, outDir: this.options.manifestDir ?? projectRoot });\n }\n if (this.options.dsn && this.options.authToken) {\n await uploadManifest({ dsn: this.options.dsn, release, ids, authToken: this.options.authToken });\n }\n });\n }\n}\n\nexport { getTagger } from './registry';\n"],"mappings":";;;;;AAOA,SAAS,eAAe,gBAAgB,yBAAyB;AAkB1D,IAAM,wBAAN,MAA4B;AAAA,EACjC,YAA6B,UAAkC,CAAC,GAAG;AAAtC;AAAA,EAAuC;AAAA,EAEpE,MAAM,UAAiC;AACrC,UAAM,cAAc,KAAK,QAAQ,eAAe,SAAS,QAAQ,WAAW,QAAQ,IAAI;AACxF,UAAM,UAAU,KAAK,QAAQ,WAAW,cAAc,EAAE,KAAK,YAAY,CAAC,EAAE;AAC5E,UAAM,SAAS,UAAU,aAAa,KAAK,QAAQ,OAAO;AAE1D,aAAS,MAAM,UAAU,WAAW,yBAAyB,YAAY;AACvE,YAAM,MAAM,OAAO,SAAS;AAC5B,UAAI,OAAO,KAAK,GAAG,EAAE,WAAW,EAAG;AACnC,UAAI,KAAK,QAAQ,kBAAkB,OAAO;AACxC,0BAAkB,EAAE,KAAK,SAAS,QAAQ,KAAK,QAAQ,eAAe,YAAY,CAAC;AAAA,MACrF;AACA,UAAI,KAAK,QAAQ,OAAO,KAAK,QAAQ,WAAW;AAC9C,cAAM,eAAe,EAAE,KAAK,KAAK,QAAQ,KAAK,SAAS,KAAK,WAAW,KAAK,QAAQ,UAAU,CAAC;AAAA,MACjG;AAAA,IACF,CAAC;AAAA,EACH;AACF;","names":[]}
|
package/dist/loader.cjs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/loader.ts
|
|
21
|
+
var loader_exports = {};
|
|
22
|
+
__export(loader_exports, {
|
|
23
|
+
default: () => loupfeedLoader
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(loader_exports);
|
|
26
|
+
|
|
27
|
+
// src/registry.ts
|
|
28
|
+
var import_build = require("@loupfeed/build");
|
|
29
|
+
var taggers = /* @__PURE__ */ new Map();
|
|
30
|
+
function getTagger(projectRoot, include) {
|
|
31
|
+
let tagger = taggers.get(projectRoot);
|
|
32
|
+
if (!tagger) {
|
|
33
|
+
tagger = (0, import_build.createTagger)({ projectRoot, include });
|
|
34
|
+
taggers.set(projectRoot, tagger);
|
|
35
|
+
}
|
|
36
|
+
return tagger;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// src/loader.ts
|
|
40
|
+
function loupfeedLoader(source) {
|
|
41
|
+
const opts = this.getOptions?.() ?? {};
|
|
42
|
+
const projectRoot = opts.projectRoot ?? this.rootContext ?? process.cwd();
|
|
43
|
+
const tagger = getTagger(projectRoot, opts.include);
|
|
44
|
+
const result = tagger.transform(source, this.resourcePath);
|
|
45
|
+
return result ? result.code : source;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=loader.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/loader.ts","../src/registry.ts"],"sourcesContent":["/**\n * Webpack loader — tags one module's JSX/TSX. Reference it in webpack config:\n * { test: /\\.[jt]sx$/, enforce: 'pre', use: '@loupfeed/webpack-plugin/loader' }\n */\n\nimport { getTagger } from './registry';\n\ninterface LoaderContext {\n resourcePath: string;\n rootContext?: string;\n getOptions?: () => { projectRoot?: string; include?: RegExp };\n}\n\nexport default function loupfeedLoader(this: LoaderContext, source: string): string {\n const opts = this.getOptions?.() ?? {};\n const projectRoot = opts.projectRoot ?? this.rootContext ?? process.cwd();\n const tagger = getTagger(projectRoot, opts.include);\n const result = tagger.transform(source, this.resourcePath);\n return result ? result.code : source;\n}\n","import { createTagger, type Tagger } from '@loupfeed/build';\n\n/**\n * The loader and the plugin run in the same Node process but are separate\n * modules; they share the per-project tagger (and its accumulating manifest)\n * through this registry, keyed by project root.\n */\nconst taggers = new Map<string, Tagger>();\n\nexport function getTagger(projectRoot: string, include?: RegExp): Tagger {\n let tagger = taggers.get(projectRoot);\n if (!tagger) {\n tagger = createTagger({ projectRoot, include });\n taggers.set(projectRoot, tagger);\n }\n return tagger;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAA0C;AAO1C,IAAM,UAAU,oBAAI,IAAoB;AAEjC,SAAS,UAAU,aAAqB,SAA0B;AACvE,MAAI,SAAS,QAAQ,IAAI,WAAW;AACpC,MAAI,CAAC,QAAQ;AACX,iBAAS,2BAAa,EAAE,aAAa,QAAQ,CAAC;AAC9C,YAAQ,IAAI,aAAa,MAAM;AAAA,EACjC;AACA,SAAO;AACT;;;ADHe,SAAR,eAAqD,QAAwB;AAClF,QAAM,OAAO,KAAK,aAAa,KAAK,CAAC;AACrC,QAAM,cAAc,KAAK,eAAe,KAAK,eAAe,QAAQ,IAAI;AACxE,QAAM,SAAS,UAAU,aAAa,KAAK,OAAO;AAClD,QAAM,SAAS,OAAO,UAAU,QAAQ,KAAK,YAAY;AACzD,SAAO,SAAS,OAAO,OAAO;AAChC;","names":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Webpack loader — tags one module's JSX/TSX. Reference it in webpack config:
|
|
3
|
+
* { test: /\.[jt]sx$/, enforce: 'pre', use: '@loupfeed/webpack-plugin/loader' }
|
|
4
|
+
*/
|
|
5
|
+
interface LoaderContext {
|
|
6
|
+
resourcePath: string;
|
|
7
|
+
rootContext?: string;
|
|
8
|
+
getOptions?: () => {
|
|
9
|
+
projectRoot?: string;
|
|
10
|
+
include?: RegExp;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
declare function loupfeedLoader(this: LoaderContext, source: string): string;
|
|
14
|
+
|
|
15
|
+
export { loupfeedLoader as default };
|
package/dist/loader.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Webpack loader — tags one module's JSX/TSX. Reference it in webpack config:
|
|
3
|
+
* { test: /\.[jt]sx$/, enforce: 'pre', use: '@loupfeed/webpack-plugin/loader' }
|
|
4
|
+
*/
|
|
5
|
+
interface LoaderContext {
|
|
6
|
+
resourcePath: string;
|
|
7
|
+
rootContext?: string;
|
|
8
|
+
getOptions?: () => {
|
|
9
|
+
projectRoot?: string;
|
|
10
|
+
include?: RegExp;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
declare function loupfeedLoader(this: LoaderContext, source: string): string;
|
|
14
|
+
|
|
15
|
+
export { loupfeedLoader as default };
|
package/dist/loader.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getTagger
|
|
3
|
+
} from "./chunk-EN5B3LN6.js";
|
|
4
|
+
|
|
5
|
+
// src/loader.ts
|
|
6
|
+
function loupfeedLoader(source) {
|
|
7
|
+
const opts = this.getOptions?.() ?? {};
|
|
8
|
+
const projectRoot = opts.projectRoot ?? this.rootContext ?? process.cwd();
|
|
9
|
+
const tagger = getTagger(projectRoot, opts.include);
|
|
10
|
+
const result = tagger.transform(source, this.resourcePath);
|
|
11
|
+
return result ? result.code : source;
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
loupfeedLoader as default
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/loader.ts"],"sourcesContent":["/**\n * Webpack loader — tags one module's JSX/TSX. Reference it in webpack config:\n * { test: /\\.[jt]sx$/, enforce: 'pre', use: '@loupfeed/webpack-plugin/loader' }\n */\n\nimport { getTagger } from './registry';\n\ninterface LoaderContext {\n resourcePath: string;\n rootContext?: string;\n getOptions?: () => { projectRoot?: string; include?: RegExp };\n}\n\nexport default function loupfeedLoader(this: LoaderContext, source: string): string {\n const opts = this.getOptions?.() ?? {};\n const projectRoot = opts.projectRoot ?? this.rootContext ?? process.cwd();\n const tagger = getTagger(projectRoot, opts.include);\n const result = tagger.transform(source, this.resourcePath);\n return result ? result.code : source;\n}\n"],"mappings":";;;;;AAae,SAAR,eAAqD,QAAwB;AAClF,QAAM,OAAO,KAAK,aAAa,KAAK,CAAC;AACrC,QAAM,cAAc,KAAK,eAAe,KAAK,eAAe,QAAQ,IAAI;AACxE,QAAM,SAAS,UAAU,aAAa,KAAK,OAAO;AAClD,QAAM,SAAS,OAAO,UAAU,QAAQ,KAAK,YAAY;AACzD,SAAO,SAAS,OAAO,OAAO;AAChC;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@loupfeed/webpack-plugin",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "loupfeed Webpack plugin + loader — opaque data-fb id injection (loader) and server-side manifest emission (plugin).",
|
|
5
|
+
"license": "FSL-1.1-ALv2",
|
|
6
|
+
"homepage": "https://loupfeed.com",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"main": "./dist/index.cjs",
|
|
10
|
+
"module": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"require": "./dist/index.cjs"
|
|
17
|
+
},
|
|
18
|
+
"./loader": {
|
|
19
|
+
"types": "./dist/loader.d.ts",
|
|
20
|
+
"import": "./dist/loader.js",
|
|
21
|
+
"require": "./dist/loader.cjs"
|
|
22
|
+
},
|
|
23
|
+
"./package.json": "./package.json"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"README.md"
|
|
28
|
+
],
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@loupfeed/build": "0.1.0"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"webpack": "^5.0.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/node": "^22.10.2",
|
|
40
|
+
"tsup": "^8.3.5",
|
|
41
|
+
"typescript": "~5.7.2",
|
|
42
|
+
"vitest": "^2.1.8"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsup",
|
|
46
|
+
"dev": "tsup --watch",
|
|
47
|
+
"typecheck": "tsc --noEmit",
|
|
48
|
+
"test": "vitest run",
|
|
49
|
+
"clean": "rm -rf dist .turbo"
|
|
50
|
+
}
|
|
51
|
+
}
|