@posthog/nextjs-config 1.6.0 → 1.6.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/config.js CHANGED
@@ -37,13 +37,14 @@ function withPostHogConfig(userNextConfig, posthogConfig) {
37
37
  return async (phase, param)=>{
38
38
  let { defaultConfig } = param;
39
39
  const { webpack: userWebPackConfig, compiler: userCompilerConfig, distDir, ...userConfig } = await resolveUserConfig(userNextConfig, phase, defaultConfig);
40
- return {
40
+ const nextConfig = {
41
41
  ...userConfig,
42
42
  distDir,
43
- productionBrowserSourceMaps: sourceMapEnabled,
44
43
  webpack: withWebpackConfig(userWebPackConfig, resolvedConfig),
45
44
  compiler: withCompilerConfig(userCompilerConfig, resolvedConfig)
46
45
  };
46
+ if (turbopackEnabled && sourceMapEnabled) nextConfig.productionBrowserSourceMaps = true;
47
+ return nextConfig;
47
48
  };
48
49
  }
49
50
  function resolveUserConfig(userNextConfig, phase, defaultConfig) {
@@ -60,13 +61,23 @@ function resolveUserConfig(userNextConfig, phase, defaultConfig) {
60
61
  function withWebpackConfig(userWebpackConfig, posthogConfig) {
61
62
  const defaultWebpackConfig = userWebpackConfig || ((config)=>config);
62
63
  const sourceMapEnabled = posthogConfig.sourcemaps.enabled;
64
+ const turbopackEnabled = (0, external_utils_js_namespaceObject.isTurbopackEnabled)();
63
65
  return (config, options)=>{
64
- const turbopackEnabled = (0, external_utils_js_namespaceObject.isTurbopackEnabled)();
65
66
  const webpackConfig = defaultWebpackConfig(config, options);
67
+ const isServer = options.isServer;
66
68
  if (sourceMapEnabled) {
67
69
  if (!turbopackEnabled) {
70
+ webpackConfig.devtool = 'hidden-source-map';
68
71
  webpackConfig.plugins = webpackConfig.plugins || [];
69
- webpackConfig.plugins.push(new webpack_plugin_namespaceObject.PosthogWebpackPlugin(posthogConfig));
72
+ let currentConfig = posthogConfig;
73
+ if (isServer) currentConfig = {
74
+ ...posthogConfig,
75
+ sourcemaps: {
76
+ ...posthogConfig.sourcemaps,
77
+ deleteAfterUpload: false
78
+ }
79
+ };
80
+ webpackConfig.plugins.push(new webpack_plugin_namespaceObject.PosthogWebpackPlugin(currentConfig));
70
81
  }
71
82
  }
72
83
  return webpackConfig;
package/dist/config.mjs CHANGED
@@ -9,13 +9,14 @@ function withPostHogConfig(userNextConfig, posthogConfig) {
9
9
  return async (phase, param)=>{
10
10
  let { defaultConfig } = param;
11
11
  const { webpack: userWebPackConfig, compiler: userCompilerConfig, distDir, ...userConfig } = await resolveUserConfig(userNextConfig, phase, defaultConfig);
12
- return {
12
+ const nextConfig = {
13
13
  ...userConfig,
14
14
  distDir,
15
- productionBrowserSourceMaps: sourceMapEnabled,
16
15
  webpack: withWebpackConfig(userWebPackConfig, resolvedConfig),
17
16
  compiler: withCompilerConfig(userCompilerConfig, resolvedConfig)
18
17
  };
18
+ if (turbopackEnabled && sourceMapEnabled) nextConfig.productionBrowserSourceMaps = true;
19
+ return nextConfig;
19
20
  };
20
21
  }
21
22
  function resolveUserConfig(userNextConfig, phase, defaultConfig) {
@@ -32,13 +33,23 @@ function resolveUserConfig(userNextConfig, phase, defaultConfig) {
32
33
  function withWebpackConfig(userWebpackConfig, posthogConfig) {
33
34
  const defaultWebpackConfig = userWebpackConfig || ((config)=>config);
34
35
  const sourceMapEnabled = posthogConfig.sourcemaps.enabled;
36
+ const turbopackEnabled = isTurbopackEnabled();
35
37
  return (config, options)=>{
36
- const turbopackEnabled = isTurbopackEnabled();
37
38
  const webpackConfig = defaultWebpackConfig(config, options);
39
+ const isServer = options.isServer;
38
40
  if (sourceMapEnabled) {
39
41
  if (!turbopackEnabled) {
42
+ webpackConfig.devtool = 'hidden-source-map';
40
43
  webpackConfig.plugins = webpackConfig.plugins || [];
41
- webpackConfig.plugins.push(new PosthogWebpackPlugin(posthogConfig));
44
+ let currentConfig = posthogConfig;
45
+ if (isServer) currentConfig = {
46
+ ...posthogConfig,
47
+ sourcemaps: {
48
+ ...posthogConfig.sourcemaps,
49
+ deleteAfterUpload: false
50
+ }
51
+ };
52
+ webpackConfig.plugins.push(new PosthogWebpackPlugin(currentConfig));
42
53
  }
43
54
  }
44
55
  return webpackConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/nextjs-config",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "description": "NextJS configuration helper for Posthog 🦔",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,10 +32,10 @@
32
32
  },
33
33
  "license": "MIT",
34
34
  "dependencies": {
35
- "@posthog/cli": "~0.5.13",
35
+ "@posthog/cli": "~0.5.16",
36
36
  "semver": "^7.7.2",
37
- "@posthog/webpack-plugin": "1.1.0",
38
- "@posthog/core": "1.6.0"
37
+ "@posthog/core": "1.6.0",
38
+ "@posthog/webpack-plugin": "1.1.2"
39
39
  },
40
40
  "keywords": [
41
41
  "posthog",
@@ -49,8 +49,8 @@
49
49
  "jest": "29.7.0",
50
50
  "next": "^15.4.1",
51
51
  "ts-jest": "29.4.0",
52
- "@posthog-tooling/rollup-utils": "1.1.0",
53
- "@posthog-tooling/tsconfig-base": "1.1.0"
52
+ "@posthog-tooling/tsconfig-base": "1.1.0",
53
+ "@posthog-tooling/rollup-utils": "1.1.0"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "next": ">12.1.0"