chore: remove blocksuite local debug option (#8386)

This PR removes the blocksuite local debug option when running `yarn dev`.

After this, to enable local debugging, simply run
```sh
yarn link <path-to-blocksuite> -A
yarn dev
```
You can disable local debugging by running
```sh
yarn unlink <path-to-blocksuite> -A
```
This commit is contained in:
L-Sun
2024-09-25 08:50:09 +00:00
parent 2c25efa1ba
commit 0416e51c83
2 changed files with 2 additions and 102 deletions

View File

@@ -18,7 +18,6 @@ const flags: BuildFlags = {
static: false,
channel: 'canary',
coverage: process.env.COVERAGE === 'true',
localBlockSuite: undefined,
};
const files = ['.env', '.env.local'];
@@ -34,7 +33,7 @@ for (const file of files) {
}
const buildFlags = process.argv.includes('--static')
? { ...flags, debugBlockSuite: false, static: true }
? { ...flags, static: true }
: ((await p.group(
{
distribution: () =>
@@ -90,11 +89,6 @@ const buildFlags = process.argv.includes('--static')
message: 'Enable coverage',
initialValue: process.env.COVERAGE === 'true',
}),
debugBlockSuite: () =>
p.confirm({
message: 'Debug blocksuite locally?',
initialValue: false,
}),
},
{
onCancel: () => {
@@ -102,7 +96,7 @@ const buildFlags = process.argv.includes('--static')
process.exit(0);
},
}
)) as BuildFlags & { debugBlockSuite: boolean });
)) as BuildFlags);
flags.distribution = buildFlags.distribution;
flags.mode = buildFlags.mode;
@@ -122,27 +116,6 @@ if (flags.distribution === 'desktop') {
};
}
if (buildFlags.debugBlockSuite) {
const { config } = await import('dotenv');
const envLocal = config({
path: join(cwd, '.env.local'),
});
const localBlockSuite = await p.text({
message: 'local blocksuite PATH',
initialValue: envLocal.error
? undefined
: envLocal.parsed?.LOCAL_BLOCK_SUITE,
});
if (typeof localBlockSuite !== 'string') {
throw new Error('local blocksuite PATH is required');
}
if (!existsSync(localBlockSuite)) {
throw new Error(`local blocksuite not found: ${localBlockSuite}`);
}
flags.localBlockSuite = localBlockSuite;
}
console.info(flags);
if (!flags.static) {

View File

@@ -91,7 +91,6 @@ export const createConfiguration: (
buildFlags: BuildFlags,
buildConfig: BUILD_CONFIG_TYPE
) => webpack.Configuration = (cwd, buildFlags, buildConfig) => {
const blocksuiteBaseDir = buildFlags.localBlockSuite;
const config = {
name: 'affine',
// to set a correct base path for the source map
@@ -146,81 +145,9 @@ export const createConfiguration: (
'.mjs': ['.mjs', '.mts'],
},
extensions: ['.js', '.ts', '.tsx'],
fallback:
blocksuiteBaseDir === undefined
? undefined
: {
events: false,
},
alias: {
yjs: join(workspaceRoot, 'node_modules', 'yjs'),
lit: join(workspaceRoot, 'node_modules', 'lit'),
'@blocksuite/affine/block-std': blocksuiteBaseDir
? join(blocksuiteBaseDir, 'packages', 'framework', 'block-std', 'src')
: join(
workspaceRoot,
'node_modules',
'@blocksuite',
'block-std',
'dist'
),
'@blocksuite/affine/blocks': blocksuiteBaseDir
? join(blocksuiteBaseDir, 'packages', 'blocks', 'src')
: join(
workspaceRoot,
'node_modules',
'@blocksuite',
'blocks',
'dist'
),
'@blocksuite/affine/presets': blocksuiteBaseDir
? join(blocksuiteBaseDir, 'packages', 'presets', 'src')
: join(
workspaceRoot,
'node_modules',
'@blocksuite',
'presets',
'dist'
),
'@blocksuite/affine/global': blocksuiteBaseDir
? join(blocksuiteBaseDir, 'packages', 'framework', 'global', 'src')
: join(
workspaceRoot,
'node_modules',
'@blocksuite',
'global',
'dist'
),
'@blocksuite/affine/store/providers/broadcast-channel':
blocksuiteBaseDir
? join(
blocksuiteBaseDir,
'packages',
'framework',
'store',
'src/providers/broadcast-channel'
)
: join(
workspaceRoot,
'node_modules',
'@blocksuite',
'store',
'dist',
'providers',
'broadcast-channel.js'
),
'@blocksuite/affine/store': blocksuiteBaseDir
? join(blocksuiteBaseDir, 'packages', 'framework', 'store', 'src')
: join(workspaceRoot, 'node_modules', '@blocksuite', 'store', 'dist'),
'@blocksuite/inline': blocksuiteBaseDir
? join(blocksuiteBaseDir, 'packages', 'framework', 'inline', 'src')
: join(
workspaceRoot,
'node_modules',
'@blocksuite',
'inline',
'dist'
),
},
},