web: add empty build-config package (#25965)

This commit is contained in:
Valery Bugakov 2021-10-12 19:14:50 +03:00 committed by GitHub
parent 3ebe2d0717
commit e5dbb2a5e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 82 additions and 9 deletions

View File

@ -49,6 +49,7 @@ jobs:
root:
- client/branded
- client/browser
- client/build-config
- client/shared
- client/web
- client/wildcard

View File

@ -59,6 +59,7 @@
"./dev/release",
"./client/web",
"./client/browser",
"./client/build-config",
"./client/shared",
"./client/branded",
"./client/wildcard",

View File

@ -0,0 +1 @@
out/

View File

@ -0,0 +1,13 @@
// @ts-check
const baseConfig = require('../../.eslintrc.js')
module.exports = {
extends: '../../.eslintrc.js',
parserOptions: {
...baseConfig.parserOptions,
project: [__dirname + '/tsconfig.json'],
},
rules: {},
overrides: baseConfig.overrides,
}

View File

@ -0,0 +1,3 @@
# Build config
Shared build configuration.

View File

@ -0,0 +1,5 @@
// @ts-check
module.exports = {
extends: '../../babel.config.js',
}

View File

@ -0,0 +1,14 @@
// @ts-check
const config = require('../../jest.config.base')
const exportedConfig = {
...config,
displayName: 'build-config',
rootDir: __dirname,
collectCoverage: false, // Collected through Puppeteer
roots: ['<rootDir>'],
verbose: true,
}
module.exports = exportedConfig

View File

@ -0,0 +1,13 @@
{
"private": true,
"name": "@sourcegraph/build-config",
"version": "0.0.1",
"description": "Sourcegraph Build configuration",
"main": "./src/index.ts",
"sideEffects": false,
"license": "Apache-2.0",
"scripts": {
"eslint": "eslint --cache 'src/**/*.[jt]s?(x)'",
"test": "jest"
}
}

View File

@ -0,0 +1 @@
export * from './paths'

View File

@ -0,0 +1,3 @@
import path from 'path'
export const ROOT_PATH = path.resolve(__dirname, '../../../')

View File

@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"sourceRoot": "src",
"rootDir": ".",
"outDir": "./out",
"baseUrl": "./src",
},
"include": ["./src/**/*", "./*.ts"],
}

View File

@ -14,5 +14,8 @@
"start:dll": "TS_NODE_TRANSPILE_ONLY=true WEBPACK_DLL_PLUGIN=true start-storybook -p 9001 -c ./src -s ./assets",
"clean:dll": "rm -rf assets/dll-bundle storybook-static/*-stats.json",
"test": "jest"
},
"devDependencies": {
"@sourcegraph/build-config": "0.0.1"
}
}

View File

@ -17,10 +17,11 @@ import webpack, {
} from 'webpack'
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
import { ROOT_PATH } from '@sourcegraph/build-config'
import { ensureDllBundleIsReady } from './dllPlugin'
import { environment } from './environment-config'
import {
rootPath,
monacoEditorPath,
dllPluginConfig,
dllBundleManifestPath,
@ -35,18 +36,18 @@ import {
const getStoriesGlob = (): string[] => {
if (process.env.STORIES_GLOB) {
return [path.resolve(rootPath, process.env.STORIES_GLOB)]
return [path.resolve(ROOT_PATH, process.env.STORIES_GLOB)]
}
// Stories in `Chromatic.story.tsx` are guarded by the `isChromatic()` check. It will result in noop in all other environments.
const chromaticStoriesGlob = path.resolve(rootPath, 'client/storybook/src/chromatic-story/Chromatic.story.tsx')
const chromaticStoriesGlob = path.resolve(ROOT_PATH, 'client/storybook/src/chromatic-story/Chromatic.story.tsx')
// Due to an issue with constant recompiling (https://github.com/storybookjs/storybook/issues/14342)
// we need to make the globs more specific (`(web|shared..)` also doesn't work). Once the above issue
// is fixed, this can be removed and watched for `client/**/*.story.tsx` again.
const directoriesWithStories = ['branded', 'browser', 'shared', 'web', 'wildcard']
const storiesGlobs = directoriesWithStories.map(packageDirectory =>
path.resolve(rootPath, `client/${packageDirectory}/src/**/*.story.tsx`)
path.resolve(ROOT_PATH, `client/${packageDirectory}/src/**/*.story.tsx`)
)
return [...storiesGlobs, chromaticStoriesGlob]
@ -59,7 +60,7 @@ const getCSSLoaders = (...loaders: RuleSetUseItem[]): RuleSetUse => [
loader: 'sass-loader',
options: {
sassOptions: {
includePaths: [path.resolve(rootPath, 'node_modules'), path.resolve(rootPath, 'client')],
includePaths: [path.resolve(ROOT_PATH, 'node_modules'), path.resolve(ROOT_PATH, 'client')],
},
},
},
@ -157,8 +158,8 @@ const config = {
config: [
__filename,
path.resolve(storybookWorkspacePath, 'babel.config.js'),
path.resolve(rootPath, 'babel.config.js'),
path.resolve(rootPath, 'postcss.config.js'),
path.resolve(ROOT_PATH, 'babel.config.js'),
path.resolve(ROOT_PATH, 'postcss.config.js'),
path.resolve(__dirname, './webpack.config.dll.ts'),
],
},
@ -172,7 +173,7 @@ const config = {
loader: require.resolve('babel-loader'),
options: {
cacheDirectory: true,
configFile: path.resolve(rootPath, 'babel.config.js'),
configFile: path.resolve(ROOT_PATH, 'babel.config.js'),
},
})

View File

@ -8,6 +8,6 @@
"baseUrl": "./src",
"jsx": "react",
},
"references": [{ "path": "../shared" }],
"references": [{ "path": "../shared" }, { "path": "../build-config" }],
"include": ["./src/**/*", "./*.ts"],
}

View File

@ -15,6 +15,7 @@ DIRS=(
client/shared
client/branded
client/browser
client/build-config
client/wildcard
client/extension-api
client/eslint-plugin-sourcegraph

View File

@ -7,6 +7,7 @@ const config = require('./jest.config.base')
module.exports = {
projects: [
'client/browser/jest.config.js',
'client/build-config/jest.config.js',
'client/shared/jest.config.js',
'client/branded/jest.config.js',
'client/web/jest.config.js',

View File

@ -1,6 +1,7 @@
{
"extends": "./tsconfig.json",
"references": [
{ "path": "client/build-config" },
{ "path": "client/shared" },
{ "path": "client/shared/src/testing" },
{ "path": "client/branded" },