@posthog/webpack-plugin 1.2.0 → 1.2.2
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/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -11
- package/dist/index.mjs +2 -3
- package/package.json +6 -3
- package/src/index.ts +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Logger } from '@posthog/core';
|
|
2
2
|
import { PluginConfig, ResolvedPluginConfig } from './config';
|
|
3
|
-
import
|
|
3
|
+
import webpack from 'webpack';
|
|
4
4
|
export * from './config';
|
|
5
5
|
export declare class PosthogWebpackPlugin {
|
|
6
6
|
resolvedConfig: ResolvedPluginConfig;
|
|
7
7
|
logger: Logger;
|
|
8
8
|
constructor(pluginConfig: PluginConfig);
|
|
9
|
-
apply(compiler:
|
|
10
|
-
processSourceMaps(compilation: Compilation, config: ResolvedPluginConfig): Promise<void>;
|
|
9
|
+
apply(compiler: webpack.Compiler): void;
|
|
10
|
+
processSourceMaps(compilation: webpack.Compilation, config: ResolvedPluginConfig): Promise<void>;
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAgB,MAAM,eAAe,CAAA;AACpD,OAAO,EAAE,YAAY,EAAiB,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAC5E,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAgB,MAAM,eAAe,CAAA;AACpD,OAAO,EAAE,YAAY,EAAiB,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAC5E,OAAO,OAAO,MAAM,SAAS,CAAA;AAI7B,cAAc,UAAU,CAAA;AAExB,qBAAa,oBAAoB;IAC7B,cAAc,EAAE,oBAAoB,CAAA;IACpC,MAAM,EAAE,MAAM,CAAA;gBAEF,YAAY,EAAE,YAAY;IAatC,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,GAAG,IAAI;IA0BjC,iBAAiB,CAAC,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;CA2CzG"}
|
package/dist/index.js
CHANGED
|
@@ -11,9 +11,6 @@ var __webpack_modules__ = {
|
|
|
11
11
|
},
|
|
12
12
|
path: function(module) {
|
|
13
13
|
module.exports = require("path");
|
|
14
|
-
},
|
|
15
|
-
webpack: function(module) {
|
|
16
|
-
module.exports = require("webpack");
|
|
17
14
|
}
|
|
18
15
|
};
|
|
19
16
|
var __webpack_module_cache__ = {};
|
|
@@ -64,10 +61,9 @@ var __webpack_exports__ = {};
|
|
|
64
61
|
});
|
|
65
62
|
var _posthog_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("@posthog/core");
|
|
66
63
|
var _config__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./config");
|
|
67
|
-
var
|
|
68
|
-
var
|
|
69
|
-
var
|
|
70
|
-
var path__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/ __webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_4__);
|
|
64
|
+
var _posthog_core_process__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("@posthog/core/process");
|
|
65
|
+
var path__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("path");
|
|
66
|
+
var path__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/ __webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_3__);
|
|
71
67
|
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
72
68
|
for(var __WEBPACK_IMPORT_KEY__ in _config__WEBPACK_IMPORTED_MODULE_1__)if ([
|
|
73
69
|
"default",
|
|
@@ -78,7 +74,7 @@ var __webpack_exports__ = {};
|
|
|
78
74
|
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
79
75
|
class PosthogWebpackPlugin {
|
|
80
76
|
apply(compiler) {
|
|
81
|
-
new
|
|
77
|
+
new compiler.webpack.SourceMapDevToolPlugin({
|
|
82
78
|
filename: '[file].map',
|
|
83
79
|
noSources: false,
|
|
84
80
|
moduleFilenameTemplate: '[resource-path]',
|
|
@@ -95,7 +91,7 @@ var __webpack_exports__ = {};
|
|
|
95
91
|
return callback();
|
|
96
92
|
};
|
|
97
93
|
if (compiler.hooks) compiler.hooks.done.tapAsync('PosthogWebpackPlugin', onDone);
|
|
98
|
-
else
|
|
94
|
+
else throw new Error('PosthogWebpackPlugin is not compatible with webpack version < 5');
|
|
99
95
|
}
|
|
100
96
|
async processSourceMaps(compilation, config) {
|
|
101
97
|
const outputDirectory = compilation.outputOptions.path;
|
|
@@ -106,13 +102,13 @@ var __webpack_exports__ = {};
|
|
|
106
102
|
const chunkArray = Array.from(compilation.chunks);
|
|
107
103
|
if (0 == chunkArray.length) return;
|
|
108
104
|
chunkArray.forEach((chunk)=>chunk.files.forEach((file)=>{
|
|
109
|
-
const chunkPath =
|
|
105
|
+
const chunkPath = path__WEBPACK_IMPORTED_MODULE_3___default().resolve(outputDirectory, file);
|
|
110
106
|
args.push('--file', chunkPath);
|
|
111
107
|
}));
|
|
112
108
|
if (config.sourcemaps.project) args.push('--project', config.sourcemaps.project);
|
|
113
109
|
if (config.sourcemaps.version) args.push('--version', config.sourcemaps.version);
|
|
114
110
|
if (config.sourcemaps.deleteAfterUpload) args.push('--delete-after');
|
|
115
|
-
await (0,
|
|
111
|
+
await (0, _posthog_core_process__WEBPACK_IMPORTED_MODULE_2__.spawnLocal)(config.cliBinaryPath, args, {
|
|
116
112
|
cwd: process.cwd(),
|
|
117
113
|
env: {
|
|
118
114
|
...process.env,
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { createLogger } from "@posthog/core";
|
|
2
2
|
import { resolveConfig } from "./config.mjs";
|
|
3
|
-
import { SourceMapDevToolPlugin } from "webpack";
|
|
4
3
|
import { spawnLocal } from "@posthog/core/process";
|
|
5
4
|
import path from "path";
|
|
6
5
|
export * from "./config.mjs";
|
|
7
6
|
class PosthogWebpackPlugin {
|
|
8
7
|
apply(compiler) {
|
|
9
|
-
new SourceMapDevToolPlugin({
|
|
8
|
+
new compiler.webpack.SourceMapDevToolPlugin({
|
|
10
9
|
filename: '[file].map',
|
|
11
10
|
noSources: false,
|
|
12
11
|
moduleFilenameTemplate: '[resource-path]',
|
|
@@ -23,7 +22,7 @@ class PosthogWebpackPlugin {
|
|
|
23
22
|
return callback();
|
|
24
23
|
};
|
|
25
24
|
if (compiler.hooks) compiler.hooks.done.tapAsync('PosthogWebpackPlugin', onDone);
|
|
26
|
-
else
|
|
25
|
+
else throw new Error('PosthogWebpackPlugin is not compatible with webpack version < 5');
|
|
27
26
|
}
|
|
28
27
|
async processSourceMaps(compilation, config) {
|
|
29
28
|
const outputDirectory = compilation.outputOptions.path;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posthog/webpack-plugin",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Webpack plugin for Posthog 🦔",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,16 +17,19 @@
|
|
|
17
17
|
"types": "./dist/index.d.ts",
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@posthog/cli": "~0.5.17",
|
|
20
|
-
"@posthog/core": "1.
|
|
20
|
+
"@posthog/core": "1.8.0"
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
23
|
"dist",
|
|
24
24
|
"src"
|
|
25
25
|
],
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"webpack": "^5"
|
|
28
|
+
},
|
|
26
29
|
"devDependencies": {
|
|
27
30
|
"@rslib/core": "0.10.6",
|
|
28
31
|
"jest": "29.7.0",
|
|
29
|
-
"webpack": "^5
|
|
32
|
+
"webpack": "^5",
|
|
30
33
|
"@posthog-tooling/tsconfig-base": "1.1.1"
|
|
31
34
|
},
|
|
32
35
|
"exports": {
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Logger, createLogger } from '@posthog/core'
|
|
2
2
|
import { PluginConfig, resolveConfig, ResolvedPluginConfig } from './config'
|
|
3
|
-
import
|
|
3
|
+
import webpack from 'webpack'
|
|
4
4
|
import { spawnLocal } from '@posthog/core/process'
|
|
5
5
|
import path from 'path'
|
|
6
6
|
|
|
@@ -23,15 +23,15 @@ export class PosthogWebpackPlugin {
|
|
|
23
23
|
)
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
apply(compiler:
|
|
27
|
-
new SourceMapDevToolPlugin({
|
|
26
|
+
apply(compiler: webpack.Compiler): void {
|
|
27
|
+
new compiler.webpack.SourceMapDevToolPlugin({
|
|
28
28
|
filename: '[file].map',
|
|
29
29
|
noSources: false,
|
|
30
30
|
moduleFilenameTemplate: '[resource-path]',
|
|
31
31
|
append: this.resolvedConfig.sourcemaps.deleteAfterUpload ? false : undefined,
|
|
32
32
|
}).apply(compiler)
|
|
33
33
|
|
|
34
|
-
const onDone = async (stats: Stats, callback: any): Promise<void> => {
|
|
34
|
+
const onDone = async (stats: webpack.Stats, callback: any): Promise<void> => {
|
|
35
35
|
callback = callback || (() => {})
|
|
36
36
|
try {
|
|
37
37
|
await this.processSourceMaps(stats.compilation, this.resolvedConfig)
|
|
@@ -45,11 +45,11 @@ export class PosthogWebpackPlugin {
|
|
|
45
45
|
if (compiler.hooks) {
|
|
46
46
|
compiler.hooks.done.tapAsync('PosthogWebpackPlugin', onDone)
|
|
47
47
|
} else {
|
|
48
|
-
|
|
48
|
+
throw new Error('PosthogWebpackPlugin is not compatible with webpack version < 5')
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
async processSourceMaps(compilation: Compilation, config: ResolvedPluginConfig): Promise<void> {
|
|
52
|
+
async processSourceMaps(compilation: webpack.Compilation, config: ResolvedPluginConfig): Promise<void> {
|
|
53
53
|
const outputDirectory = compilation.outputOptions.path
|
|
54
54
|
|
|
55
55
|
// chunks are output outside of the output directory for server chunks
|