Skip to content

Commit bf1cd10

Browse files
author
winjo
committed
build: 构建 global 包用于 script 引入
1 parent 6a97016 commit bf1cd10

9 files changed

Lines changed: 54 additions & 48 deletions

File tree

packages/alex/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "@alipay/alex",
55
"main": "lib/index.js",
66
"typings": "lib/index.d.ts",
7+
"unpkg": "bundle/alex.global.js",
78
"files": [
89
"lib",
910
"bin",
Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,34 @@
1-
import { Injectable, Provider } from '@ali/common-di';
2-
import { BrowserModule } from '@ali/ide-core-browser';
1+
import { Injectable, Provider, Autowired } from '@ali/common-di';
2+
import {
3+
BrowserModule,
4+
KeybindingContribution,
5+
Domain,
6+
KeybindingRegistry,
7+
} from '@ali/ide-core-browser';
8+
import { RuntimeConfig } from '@alipay/alex-core';
39
import { ExtensionActivateContribution } from './extension/extension.contribution';
410
import { AlexCommandContribution } from './commands';
511

12+
@Domain(KeybindingContribution)
13+
class AlexContribution implements KeybindingContribution {
14+
@Autowired(RuntimeConfig)
15+
private readonly runtimeConfig: RuntimeConfig;
16+
17+
registerKeybindings(keybindings: KeybindingRegistry) {
18+
// 自定义注销的快捷键
19+
if (this.runtimeConfig.unregisterKeybindings) {
20+
this.runtimeConfig.unregisterKeybindings.forEach((binding) => {
21+
keybindings.unregisterKeybinding(binding);
22+
});
23+
}
24+
}
25+
}
26+
627
@Injectable()
728
export class AlexModule extends BrowserModule {
8-
providers: Provider[] = [ExtensionActivateContribution, AlexCommandContribution];
29+
providers: Provider[] = [
30+
ExtensionActivateContribution,
31+
AlexCommandContribution,
32+
AlexContribution,
33+
];
934
}

packages/alex/src/core/extension/metadata.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const IDETheme: IExtensionBasicMetadata = {
3333
extension: {
3434
publisher: 'kaitian',
3535
name: 'ide-dark-theme',
36-
version: '2.3.2',
36+
version: '2.4.0',
3737
},
3838
packageJSON: {
3939
name: 'ide-dark-theme',

packages/cli/src/util/serve-file.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const createServer = async (dirs: string[], uri: Uri) => {
2929
}
3030
const filepath = pathname.slice(`${uri.path}${targetDir}`.length);
3131
send(req, filepath, {
32-
cacheControl: false,
32+
maxAge: 0,
3333
root: targetDir,
3434
})
3535
.on('headers', (res: http.ServerResponse) => {

packages/integrations/src/startup/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import css from '@alipay/alex/extensions/alex.css-language-features-worker';
1212
import html from '@alipay/alex/extensions/alex.html-language-features-worker';
1313
import json from '@alipay/alex/extensions/alex.json-language-features-worker';
1414
import markdown from '@alipay/alex/extensions/alex.markdown-language-features-worker';
15-
import typescript from '@alipay/alex/extensions/alitcode.typescript-language-features-worker';
15+
import typescript from '@alipay/alex/extensions/alex.typescript-language-features-worker';
1616
import lsif from '@alipay/alex/extensions/cloud-ide.vscode-lsif';
1717

1818
import { LocalExtensionModule } from '../common/local-extension.module';

packages/toolkit/webpack/config.build.js

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const libBundle = createWebpackConfig({
5959
},
6060
});
6161

62-
const umdBundle = createWebpackConfig({
62+
const globalBundle = createWebpackConfig({
6363
mode: 'production',
6464
tsconfigPath: path.join(__dirname, '../../../tsconfig.json'),
6565
outputPath: path.join(__dirname, '../../alex/bundle'),
@@ -70,34 +70,19 @@ const umdBundle = createWebpackConfig({
7070
webpackConfig: {
7171
context: path.join(__dirname, '../../..'),
7272
entry: {
73-
[config.appUmdEntry]: './packages/alex/src',
74-
[config.appUmdMinEntry]: './packages/alex/src',
73+
[config.appGlobalEntry]: './packages/alex/src',
74+
[config.appGlobalMinEntry]: './packages/alex/src',
7575
},
7676
// 此处 bundle 的包仅作为 commonjs 使用,但因为 external 原因会导致 webpack4 加载 bundle 出错,因此还是使用 umd
7777
output: {
7878
library: 'Alex',
79-
libraryTarget: 'umd',
79+
libraryTarget: 'global',
8080
},
8181
externals: [
8282
{
83-
react: {
84-
root: 'React',
85-
commonjs2: 'react',
86-
commonjs: 'react',
87-
amd: 'react',
88-
},
89-
'react-dom': {
90-
root: 'ReactDOM',
91-
commonjs2: 'react-dom',
92-
commonjs: 'react-dom',
93-
amd: 'react-dom',
94-
},
95-
moment: {
96-
root: 'moment',
97-
commonjs2: 'moment',
98-
commonjs: 'moment',
99-
amd: 'moment',
100-
},
83+
react: 'react',
84+
'react-dom': 'ReactDOM',
85+
moment: 'moment',
10186
},
10287
],
10388
optimization: {
@@ -116,4 +101,4 @@ const umdBundle = createWebpackConfig({
116101
},
117102
});
118103

119-
module.exports = libBundle;
104+
module.exports = [libBundle, globalBundle];

packages/toolkit/webpack/config.languages.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,21 @@ module.exports = () => {
66
return {
77
context: path.join(__dirname, '../../..'),
88
entry: {
9-
[config.languageUmdEntry]: './packages/alex/languages/index.js',
10-
[config.languageUmdMinEntry]: './packages/alex/languages/index.js',
9+
[config.languageGlobalEntry]: './packages/alex/languages/index.js',
10+
[config.languageGlobalMinEntry]: './packages/alex/languages/index.js',
1111
},
1212
output: {
1313
path: path.resolve(__dirname, '../../alex/languages'),
1414
library: 'AlexLanguages',
15-
libraryTarget: 'umd',
15+
libraryTarget: 'global',
1616
},
1717
devtool: false,
1818
mode: 'production',
1919
resolve: {
2020
extensions: ['.js', '.json'],
2121
},
2222
externals: {
23-
'@alipay/alex-registry': {
24-
root: ['Alex', 'Registry'],
25-
commonjs2: ['@alipay/alex/bundle/alex.umd', 'Registry'],
26-
commonjs: ['@alipay/alex/bundle/alex.umd', 'Registry'],
27-
amd: ['@alipay/alex/bundle/alex.umd', 'Registry'],
28-
},
23+
'@alipay/alex-registry': ['Alex', 'Registry'],
2924
},
3025
optimization: {
3126
minimize: true,

packages/toolkit/webpack/util/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ exports.nodePolyfill = {
3333

3434
exports.config = {
3535
appEntry: 'alex',
36-
appUmdEntry: 'alex.umd',
37-
appUmdMinEntry: 'alex.umd.min',
36+
appGlobalEntry: 'alex.global',
37+
appGlobalMinEntry: 'alex.global.min',
3838
editorEntry: 'alex.editor',
3939
editorAllEntry: 'alex.editor.all',
4040
workerEntry: 'worker-host',
4141
webviewEntry: 'webview',
42-
languageUmdEntry: 'languages.umd',
43-
languageUmdMinEntry: 'languages.umd.min',
42+
languageGlobalEntry: 'languages.global',
43+
languageGlobalMinEntry: 'languages.global.min',
4444
};
4545

4646
// just for shared

scripts/generate.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ const { generateLanguages, generateModules, generateShims } = require('./utils/g
55
invoke(async () => {
66
await Promise.all([generateLanguages(), generateModules(), generateShims()]);
77

8-
// try {
9-
// await exec('yarn workspace @alipay/alex-toolkit build:languages');
10-
// } catch (err) {
11-
// signale.error('build languages 失败')
12-
// throw err
13-
// }
8+
try {
9+
await exec('yarn workspace @alipay/alex-toolkit build:languages');
10+
} catch (err) {
11+
signale.error('build languages 失败');
12+
throw err;
13+
}
1414
});

0 commit comments

Comments
 (0)