@atls/code-service 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build.d.ts +8 -0
- package/dist/build.js +41 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +14 -0
- package/dist/watch.d.ts +5 -0
- package/dist/watch.js +14 -0
- package/dist/webpack/externals.d.ts +3 -0
- package/dist/webpack/externals.js +79 -0
- package/dist/webpack/index.d.ts +1 -0
- package/dist/webpack/index.js +13 -0
- package/dist/webpack/resolve.d.ts +1 -0
- package/dist/webpack/resolve.js +14 -0
- package/dist/webpack/webpack.config.d.ts +6 -0
- package/dist/webpack/webpack.config.js +55 -0
- package/package.json +43 -0
- package/tsconfig.stub.json +1 -0
package/dist/build.d.ts
ADDED
package/dist/build.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.build = void 0;
|
|
7
|
+
const webpack_1 = __importDefault(require("webpack"));
|
|
8
|
+
const webpack_2 = require("./webpack");
|
|
9
|
+
const build = async ({ cwd }, plugins) => {
|
|
10
|
+
const config = await (0, webpack_2.createWebpackConfig)(cwd, 'production', plugins);
|
|
11
|
+
const compiler = (0, webpack_1.default)(config);
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
compiler.run((error, stats) => {
|
|
14
|
+
if (error) {
|
|
15
|
+
if (!error.message) {
|
|
16
|
+
reject(error);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
resolve({
|
|
20
|
+
errors: [{ message: error.message }],
|
|
21
|
+
warnings: [],
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else if (stats) {
|
|
26
|
+
const { errors = [], warnings = [] } = stats.toJson();
|
|
27
|
+
resolve({
|
|
28
|
+
errors: errors.map((error) => ({ message: error.message })),
|
|
29
|
+
warnings: warnings.map((warning) => ({ message: warning.message })),
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
resolve({
|
|
34
|
+
errors: [],
|
|
35
|
+
warnings: [],
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
exports.build = build;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./build"), exports);
|
|
14
|
+
__exportStar(require("./watch"), exports);
|
package/dist/watch.d.ts
ADDED
package/dist/watch.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.watch = void 0;
|
|
7
|
+
const webpack_1 = __importDefault(require("webpack"));
|
|
8
|
+
const webpack_2 = require("./webpack");
|
|
9
|
+
const watch = async ({ cwd }, plugins = [], callback = (error) => undefined) => {
|
|
10
|
+
const config = await (0, webpack_2.createWebpackConfig)(cwd, 'development', plugins);
|
|
11
|
+
const compiler = (0, webpack_1.default)(config);
|
|
12
|
+
return compiler.watch({}, callback);
|
|
13
|
+
};
|
|
14
|
+
exports.watch = watch;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getExternals = exports.getUnpluggedDependencies = exports.unusedExternals = void 0;
|
|
7
|
+
const core_1 = require("@yarnpkg/core");
|
|
8
|
+
const core_2 = require("@yarnpkg/core");
|
|
9
|
+
const cli_1 = require("@yarnpkg/cli");
|
|
10
|
+
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
11
|
+
const path_1 = __importDefault(require("path"));
|
|
12
|
+
const fs_1 = require("fs");
|
|
13
|
+
const FORCE_UNPLUGGED_PACKAGES = new Set([
|
|
14
|
+
'nan',
|
|
15
|
+
'node-gyp',
|
|
16
|
+
'node-pre-gyp',
|
|
17
|
+
'node-addon-api',
|
|
18
|
+
'fsevents',
|
|
19
|
+
'core-js',
|
|
20
|
+
'core-js-pure',
|
|
21
|
+
'protobufjs',
|
|
22
|
+
]);
|
|
23
|
+
exports.unusedExternals = [
|
|
24
|
+
'cli-color',
|
|
25
|
+
'flaschenpost',
|
|
26
|
+
'amqp-connection-manager',
|
|
27
|
+
'kafkajs',
|
|
28
|
+
'amqplib',
|
|
29
|
+
'redis',
|
|
30
|
+
'mqtt',
|
|
31
|
+
'nats',
|
|
32
|
+
'@nestjs/websockets',
|
|
33
|
+
'typeorm-aurora-data-api-driver',
|
|
34
|
+
'react-native-sqlite-storage',
|
|
35
|
+
'@sap/hana-client',
|
|
36
|
+
'better-sqlite3',
|
|
37
|
+
'mongodb',
|
|
38
|
+
'oracledb',
|
|
39
|
+
'pg-native',
|
|
40
|
+
'mysql',
|
|
41
|
+
'ioredis',
|
|
42
|
+
'hdb-pool',
|
|
43
|
+
'mysql2',
|
|
44
|
+
'mssql',
|
|
45
|
+
'sql.js',
|
|
46
|
+
'pnpapi',
|
|
47
|
+
'next',
|
|
48
|
+
];
|
|
49
|
+
const getUnpluggedDependencies = async () => {
|
|
50
|
+
const configuration = await core_1.Configuration.find(process.cwd(), (0, cli_1.getPluginConfiguration)());
|
|
51
|
+
const pnpUnpluggedFolder = configuration.get('pnpUnpluggedFolder');
|
|
52
|
+
const dependenciesNames = new Set();
|
|
53
|
+
const entries = await (0, fast_glob_1.default)('*/node_modules/*/package.json', {
|
|
54
|
+
cwd: pnpUnpluggedFolder,
|
|
55
|
+
});
|
|
56
|
+
await Promise.all(entries
|
|
57
|
+
.map((entry) => path_1.default.join(pnpUnpluggedFolder, entry))
|
|
58
|
+
.map(async (entry) => {
|
|
59
|
+
try {
|
|
60
|
+
const { name } = JSON.parse((await fs_1.promises.readFile(entry)).toString());
|
|
61
|
+
if (name && !FORCE_UNPLUGGED_PACKAGES.has(name)) {
|
|
62
|
+
dependenciesNames.add(name);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch (_a) { }
|
|
66
|
+
}));
|
|
67
|
+
return dependenciesNames;
|
|
68
|
+
};
|
|
69
|
+
exports.getUnpluggedDependencies = getUnpluggedDependencies;
|
|
70
|
+
const getExternals = async (cwd) => {
|
|
71
|
+
var _a, _b;
|
|
72
|
+
const configuration = await core_1.Configuration.find(process.cwd(), (0, cli_1.getPluginConfiguration)());
|
|
73
|
+
const { project } = await core_2.Project.find(configuration, process.cwd());
|
|
74
|
+
const workspace = project.getWorkspaceByFilePath(cwd);
|
|
75
|
+
const workspaceExternals = Object.keys(((_b = (_a = workspace === null || workspace === void 0 ? void 0 : workspace.manifest) === null || _a === void 0 ? void 0 : _a.raw) === null || _b === void 0 ? void 0 : _b.externalDependencies) || {});
|
|
76
|
+
const unpluggedExternals = Array.from(await (0, exports.getUnpluggedDependencies)());
|
|
77
|
+
return Array.from(new Set([...workspaceExternals, ...unpluggedExternals, ...exports.unusedExternals]));
|
|
78
|
+
};
|
|
79
|
+
exports.getExternals = getExternals;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './webpack.config';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./webpack.config"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getResolveAliases: (cwd: string) => Promise<any>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getResolveAliases = void 0;
|
|
4
|
+
const core_1 = require("@yarnpkg/core");
|
|
5
|
+
const core_2 = require("@yarnpkg/core");
|
|
6
|
+
const cli_1 = require("@yarnpkg/cli");
|
|
7
|
+
const getResolveAliases = async (cwd) => {
|
|
8
|
+
var _a, _b, _c;
|
|
9
|
+
const configuration = await core_1.Configuration.find(process.cwd(), (0, cli_1.getPluginConfiguration)());
|
|
10
|
+
const { project } = await core_2.Project.find(configuration, process.cwd());
|
|
11
|
+
const workspace = project.getWorkspaceByFilePath(cwd);
|
|
12
|
+
return ((_c = (_b = (_a = workspace === null || workspace === void 0 ? void 0 : workspace.manifest) === null || _a === void 0 ? void 0 : _a.raw) === null || _b === void 0 ? void 0 : _b.resolve) === null || _c === void 0 ? void 0 : _c.alias) || [];
|
|
13
|
+
};
|
|
14
|
+
exports.getResolveAliases = getResolveAliases;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createWebpackConfig = void 0;
|
|
7
|
+
const webpack_chain_1 = __importDefault(require("webpack-chain"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const webpack_1 = __importDefault(require("webpack"));
|
|
10
|
+
const code_typescript_1 = require("@atls/code-typescript");
|
|
11
|
+
const externals_1 = require("./externals");
|
|
12
|
+
const resolve_1 = require("./resolve");
|
|
13
|
+
const createWebpackConfig = async (cwd, environment, plugins = []) => {
|
|
14
|
+
const externals = (await (0, externals_1.getExternals)(cwd)).reduce((result, dependency) => (Object.assign(Object.assign({}, result), { [dependency]: `commonjs2 ${dependency}` })), {});
|
|
15
|
+
const config = new webpack_chain_1.default();
|
|
16
|
+
config
|
|
17
|
+
.mode(environment)
|
|
18
|
+
.bail(environment === 'production')
|
|
19
|
+
.target('async-node')
|
|
20
|
+
.optimization.minimize(false);
|
|
21
|
+
config.node.set('__dirname', false).set('__filename', false);
|
|
22
|
+
config.entry('index').add(path_1.default.join(cwd, 'src/index'));
|
|
23
|
+
config.output.path(path_1.default.join(cwd, 'dist')).filename('[name].js');
|
|
24
|
+
config.resolve.extensions.add('.tsx').add('.ts').add('.js');
|
|
25
|
+
const aliases = await (0, resolve_1.getResolveAliases)(cwd);
|
|
26
|
+
aliases.forEach((target) => {
|
|
27
|
+
config.resolve.alias.set(target, require.resolve(target, { paths: [cwd] }));
|
|
28
|
+
});
|
|
29
|
+
config.externals(externals);
|
|
30
|
+
config.when(environment === 'development', () => {
|
|
31
|
+
config.plugin('hot').use(webpack_1.default.HotModuleReplacementPlugin);
|
|
32
|
+
});
|
|
33
|
+
plugins.forEach((plugin) => {
|
|
34
|
+
config.plugin(plugin.name).use(plugin.use, plugin.args);
|
|
35
|
+
});
|
|
36
|
+
config.module
|
|
37
|
+
.rule('ts')
|
|
38
|
+
.test(/.tsx?$/)
|
|
39
|
+
.use('ts')
|
|
40
|
+
.loader(require.resolve('ts-loader'))
|
|
41
|
+
.options({
|
|
42
|
+
transpileOnly: true,
|
|
43
|
+
experimentalWatchApi: true,
|
|
44
|
+
compilerOptions: Object.assign(Object.assign({}, code_typescript_1.base.compilerOptions), { sourceMap: true }),
|
|
45
|
+
configFile: path_1.default.join(__dirname, '../../tsconfig.stub.json'),
|
|
46
|
+
});
|
|
47
|
+
config.module
|
|
48
|
+
.rule('protos')
|
|
49
|
+
.test(/\.proto$/)
|
|
50
|
+
.use('proto')
|
|
51
|
+
.loader(require.resolve('@atls/webpack-proto-imports-loader'));
|
|
52
|
+
config.devtool(environment === 'production' ? 'source-map' : 'eval-cheap-module-source-map');
|
|
53
|
+
return config.toConfig();
|
|
54
|
+
};
|
|
55
|
+
exports.createWebpackConfig = createWebpackConfig;
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atls/code-service",
|
|
3
|
+
"version": "0.0.7",
|
|
4
|
+
"license": "BSD-3-Clause",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"tsconfig.stub.json",
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "builder build library",
|
|
12
|
+
"postpack": "rm -rf dist",
|
|
13
|
+
"prepack": "yarn run build"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@atls/tools-builder": "0.0.0",
|
|
17
|
+
"@types/file-loader": "5.0.1",
|
|
18
|
+
"@types/jest": "^27.0.1",
|
|
19
|
+
"@types/node": "^16.7.10",
|
|
20
|
+
"@types/protocol-buffers-schema": "3.4.1",
|
|
21
|
+
"@types/wait-for-localhost": "3.1.0",
|
|
22
|
+
"@types/webpack": "^5.28.0",
|
|
23
|
+
"@yarnpkg/fslib": "^2.6.0-rc.2",
|
|
24
|
+
"wait-for-localhost": "^3.3.0"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"main": "dist/index.js",
|
|
28
|
+
"typings": "dist/index.d.ts"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@atls/code-typescript": "0.0.5",
|
|
32
|
+
"@atls/webpack-proto-imports-loader": "0.0.5",
|
|
33
|
+
"@yarnpkg/cli": "^3.1.0-rc.2",
|
|
34
|
+
"@yarnpkg/core": "^3.1.0-rc.3",
|
|
35
|
+
"fast-glob": "^3.2.7",
|
|
36
|
+
"string-replace-loader": "^3.0.3",
|
|
37
|
+
"ts-loader": "^9.2.5",
|
|
38
|
+
"typescript": "^4.4.2",
|
|
39
|
+
"webpack": "^5.51.1",
|
|
40
|
+
"webpack-chain": "^6.5.1"
|
|
41
|
+
},
|
|
42
|
+
"typings": "dist/index.d.ts"
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|