forked from crowetic/commerce
Remove tsconfig.js and add back yarn.lock (#390)
* Removed tsconfig.js * Added back yarn.lock
This commit is contained in:
parent
cb6d70570d
commit
08813be880
@ -57,11 +57,27 @@ function withCommerceConfig(nextConfig = {}) {
|
|||||||
|
|
||||||
// Update paths in `tsconfig.json` to point to the selected provider
|
// Update paths in `tsconfig.json` to point to the selected provider
|
||||||
if (config.commerce.updateTSConfig !== false) {
|
if (config.commerce.updateTSConfig !== false) {
|
||||||
const staticTsconfigPath = path.join(process.cwd(), 'tsconfig.json')
|
const tsconfigPath = path.join(process.cwd(), 'tsconfig.json')
|
||||||
const tsconfig = require('../../tsconfig.js')
|
const tsconfig = require(tsconfigPath)
|
||||||
|
|
||||||
|
tsconfig.compilerOptions.paths['@framework'] = [`framework/${name}`]
|
||||||
|
tsconfig.compilerOptions.paths['@framework/*'] = [`framework/${name}/*`]
|
||||||
|
|
||||||
|
// When running for production it may be useful to exclude the other providers
|
||||||
|
// from TS checking
|
||||||
|
if (process.env.VERCEL) {
|
||||||
|
const exclude = tsconfig.exclude.filter(
|
||||||
|
(item) => !item.startsWith('framework/')
|
||||||
|
)
|
||||||
|
|
||||||
|
tsconfig.exclude = PROVIDERS.reduce((exclude, current) => {
|
||||||
|
if (current !== name) exclude.push(`framework/${current}`)
|
||||||
|
return exclude
|
||||||
|
}, exclude)
|
||||||
|
}
|
||||||
|
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
staticTsconfigPath,
|
tsconfigPath,
|
||||||
prettier.format(JSON.stringify(tsconfig), { parser: 'json' })
|
prettier.format(JSON.stringify(tsconfig), { parser: 'json' })
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
58
tsconfig.js
58
tsconfig.js
@ -1,58 +0,0 @@
|
|||||||
const PROVIDERS = ['bigcommerce', 'shopify', 'swell', 'vendure', 'saleor']
|
|
||||||
|
|
||||||
function getProviderName() {
|
|
||||||
return (
|
|
||||||
process.env.COMMERCE_PROVIDER ||
|
|
||||||
(process.env.BIGCOMMERCE_STOREFRONT_API_URL
|
|
||||||
? 'bigcommerce'
|
|
||||||
: process.env.NEXT_PUBLIC_SHOPIFY_STORE_DOMAIN
|
|
||||||
? 'shopify'
|
|
||||||
: process.env.NEXT_PUBLIC_SWELL_STORE_ID
|
|
||||||
? 'swell'
|
|
||||||
: 'local')
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const name = getProviderName()
|
|
||||||
const EXCLUDED_PROVIDERS = PROVIDERS.filter((p) => p !== name).map(
|
|
||||||
(p) => `./framework/${p}`
|
|
||||||
)
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
compilerOptions: {
|
|
||||||
baseUrl: '.',
|
|
||||||
target: 'esnext',
|
|
||||||
lib: ['dom', 'dom.iterable', 'esnext'],
|
|
||||||
allowJs: true,
|
|
||||||
skipLibCheck: true,
|
|
||||||
strict: true,
|
|
||||||
forceConsistentCasingInFileNames: true,
|
|
||||||
noEmit: true,
|
|
||||||
esModuleInterop: true,
|
|
||||||
module: 'esnext',
|
|
||||||
moduleResolution: 'node',
|
|
||||||
resolveJsonModule: true,
|
|
||||||
isolatedModules: true,
|
|
||||||
jsx: 'preserve',
|
|
||||||
incremental: true,
|
|
||||||
paths: {
|
|
||||||
'@lib/*': ['lib/*'],
|
|
||||||
'@utils/*': ['utils/*'],
|
|
||||||
'@config/*': ['config/*'],
|
|
||||||
'@assets/*': ['assets/*'],
|
|
||||||
'@components/*': ['components/*'],
|
|
||||||
'@commerce': ['framework/commerce'],
|
|
||||||
'@commerce/*': ['framework/commerce/*'],
|
|
||||||
// Update paths to point to the selected provider
|
|
||||||
'@framework': [`framework/${name}`],
|
|
||||||
'@framework/*': [`framework/${name}/*`],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
include: ['next-env.d.ts', '**/*.d.ts', '**/*.ts', '**/*.tsx', '**/*.js'],
|
|
||||||
exclude: [
|
|
||||||
'node_modules',
|
|
||||||
// It may be useful to exclude the other providers
|
|
||||||
// from TS checking
|
|
||||||
...EXCLUDED_PROVIDERS,
|
|
||||||
],
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user