diff --git a/package-lock.json b/package-lock.json index 0e9ffe7c5..07cf86fc7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7998,8 +7998,8 @@ "@types/node": "^15.12.4", "@types/react": "^17.0.8", "@vercel/fetch": "^6.1.1", - "deepmerge": "*", - "import-cwd": "*", + "deepmerge": "^4.2.2", + "import-cwd": "^3.0.0", "js-cookie": "^2.2.1", "next": "^12.0.3", "react": "^17.0.2", diff --git a/packages/commerce/package.json b/packages/commerce/package.json index eb7afe3bd..b5134b23c 100644 --- a/packages/commerce/package.json +++ b/packages/commerce/package.json @@ -9,6 +9,7 @@ "sideEffects": false, "type": "module", "exports": { + ".": "./dist/index.js", "./*": "./dist/*.js", "./config": "./dist/config.cjs" }, diff --git a/packages/commerce/tsconfig.json b/packages/commerce/tsconfig.json index 7dd55c2ce..d5394d519 100644 --- a/packages/commerce/tsconfig.json +++ b/packages/commerce/tsconfig.json @@ -15,7 +15,7 @@ "resolveJsonModule": true, "isolatedModules": true, "pretty": true, - "jsx": "preserve" + "jsx": "react-jsx" }, "include": ["src"], "exclude": ["node_modules", "dist"] diff --git a/packages/local/package.json b/packages/local/package.json index 92e0061df..9193aabcc 100644 --- a/packages/local/package.json +++ b/packages/local/package.json @@ -9,6 +9,7 @@ "sideEffects": false, "type": "module", "exports": { + ".": "./dist/index.js", "./*": "./dist/*.js", "./next.config": "./dist/next.config.cjs" }, diff --git a/packages/local/tsconfig.json b/packages/local/tsconfig.json index 7dd55c2ce..d5394d519 100644 --- a/packages/local/tsconfig.json +++ b/packages/local/tsconfig.json @@ -15,7 +15,7 @@ "resolveJsonModule": true, "isolatedModules": true, "pretty": true, - "jsx": "preserve" + "jsx": "react-jsx" }, "include": ["src"], "exclude": ["node_modules", "dist"] diff --git a/site/commerce-config.js b/site/commerce-config.js index dff03919b..fe2189978 100644 --- a/site/commerce-config.js +++ b/site/commerce-config.js @@ -42,8 +42,6 @@ function withCommerceConfig(nextConfig = {}) { const { commerce } = config const { provider } = commerce - console.log('CONFIG', config) - if (!provider) { throw new Error( `The commerce provider is missing, please add a valid provider name or its environment variables` @@ -64,9 +62,19 @@ function withCommerceConfig(nextConfig = {}) { commerce.tsconfigPath || 'tsconfig.json' ) const tsconfig = require(tsconfigPath) + // The module path is a symlink in node_modules + // -> /node_modules/[name]/dist/index.js + const absolutePath = require.resolve(provider) + // but we want references to go to the real path in /packages instead + // -> packages/[name]/dist/index.js + const relativePath = path.relative(process.cwd(), absolutePath) + // -> /packages/[name]/src + const modulePath = path.join(relativePath, '../../dist') - tsconfig.compilerOptions.paths['@framework'] = [`${provider}`] - tsconfig.compilerOptions.paths['@framework/*'] = [`${provider}/*`] + console.log('PATH', modulePath) + + tsconfig.compilerOptions.paths['@framework'] = [`${modulePath}`] + tsconfig.compilerOptions.paths['@framework/*'] = [`${modulePath}/*`] fs.writeFileSync( tsconfigPath, diff --git a/site/tsconfig.json b/site/tsconfig.json index cd3b68ca8..cbefb0678 100644 --- a/site/tsconfig.json +++ b/site/tsconfig.json @@ -23,8 +23,8 @@ "@components/*": ["components/*"], "@commerce": ["framework/commerce"], "@commerce/*": ["framework/commerce/*"], - "@framework": ["@vercel/commerce-local"], - "@framework/*": ["@vercel/commerce-local/*"] + "@framework": ["../packages/local/dist"], + "@framework/*": ["../packages/local/dist/*"] } }, "include": ["next-env.d.ts", "**/*.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"],