nitrostack 1.0.7 → 1.0.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitrostack",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "NitroStack - Build powerful MCP servers with TypeScript",
5
5
  "type": "module",
6
6
  "main": "dist/core/index.js",
@@ -105,4 +105,4 @@
105
105
  "url": "https://github.com/abhishekpanditofficial/nitrostack/issues"
106
106
  },
107
107
  "homepage": "https://nitrostack.vercel.app"
108
- }
108
+ }
@@ -1,8 +1,10 @@
1
1
  import path from 'path';
2
2
  import { fileURLToPath } from 'url';
3
+ import { createRequire } from 'module';
3
4
 
4
5
  const __filename = fileURLToPath(import.meta.url);
5
6
  const __dirname = path.dirname(__filename);
7
+ const require = createRequire(import.meta.url);
6
8
 
7
9
  /** @type {import('next').NextConfig} */
8
10
  const nextConfig = {
@@ -16,23 +18,46 @@ const nextConfig = {
16
18
  eslint: {
17
19
  ignoreDuringBuilds: true,
18
20
  },
19
- webpack: (config, { defaultLoaders, isServer }) => {
21
+ transpilePackages: ['nitrostack'],
22
+ webpack: (config) => {
20
23
  // Explicitly configure webpack to resolve @ alias
21
24
  config.resolve.alias = {
22
25
  ...config.resolve.alias,
23
26
  '@': __dirname,
24
27
  };
25
28
 
26
- // Ensure our lib and components directories are included in compilation
27
- // Use Next.js's default TypeScript loader
28
29
  const libPath = path.resolve(__dirname, 'lib');
29
30
  const componentsPath = path.resolve(__dirname, 'components');
30
31
 
31
- // Add a rule for our TypeScript files using Next.js's default loader
32
+ // Create a high-priority rule that ensures TS/TSX in node_modules/nitrostack are transpiled
33
+ const forceTsTranspileRule = {
34
+ test: /\.(ts|tsx)$/,
35
+ // Do not exclude our package even if under node_modules
36
+ exclude: (modulePath) => {
37
+ // Never exclude files from nitrostack package
38
+ if (modulePath.includes(`${path.sep}node_modules${path.sep}nitrostack${path.sep}`)) {
39
+ return false;
40
+ }
41
+ // Otherwise, apply default exclude for node_modules
42
+ return modulePath.includes(`${path.sep}node_modules${path.sep}`);
43
+ },
44
+ use: {
45
+ loader: require.resolve('next/dist/build/webpack/loaders/next-swc-loader'),
46
+ },
47
+ };
48
+
49
+ const oneOfRule = config.module.rules.find((rule) => Array.isArray(rule.oneOf));
50
+ if (oneOfRule && Array.isArray(oneOfRule.oneOf)) {
51
+ oneOfRule.oneOf.unshift(forceTsTranspileRule);
52
+ } else {
53
+ config.module.rules.unshift(forceTsTranspileRule);
54
+ }
55
+
56
+ // Also add a specific include-based rule for our lib/components as a fallback
32
57
  config.module.rules.push({
33
58
  test: /\.(ts|tsx)$/,
34
59
  include: [libPath, componentsPath],
35
- use: defaultLoaders.babel,
60
+ use: require.resolve('next/dist/build/webpack/loaders/next-swc-loader'),
36
61
  });
37
62
 
38
63
  return config;