mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-14 20:48:00 +00:00
### Description
See
454996d496
for manual changes (excluded auto-generated formatting changes)
### Why
Because the toolsets for old clang-format is out-of-date. This reduces
the development efficiency.
- The NPM package `clang-format` is already in maintenance mode. not
updated since 2 years ago.
- The VSCode extension for clang-format is not maintained for a while,
and a recent Node.js security update made it not working at all in
Windows.
No one in community seems interested in fixing those.
Choose Prettier as it is the most popular TS/JS formatter.
### How to merge
It's easy to break the build:
- Be careful of any new commits on main not included in this PR.
- Be careful that after this PR is merged, other PRs that already passed
CI can merge.
So, make sure there is no new commits before merging this one, and
invalidate js PRs that already passed CI, force them to merge to latest.
71 lines
1.9 KiB
JavaScript
71 lines
1.9 KiB
JavaScript
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
|
|
'use strict';
|
|
|
|
import webpack from 'webpack';
|
|
import { resolve } from 'node:path';
|
|
import { DEFAULT_ES_VERSION, addCopyrightBannerPlugin } from '../webpack.shared.mjs';
|
|
|
|
function buildConfig({
|
|
suffix = '.js', // '.js', '.min.js', ...
|
|
format = 'umd', // 'umd', 'commonjs'
|
|
target = 'web', // 'web', 'node'
|
|
esVersion = DEFAULT_ES_VERSION, // 'es5', 'es6', ...
|
|
mode = 'production', // 'development', 'production'
|
|
devtool = 'source-map', // 'inline-source-map', 'source-map'
|
|
}) {
|
|
// output file name
|
|
const filename = `ort-common${suffix}`;
|
|
|
|
// variable name of the exported object.
|
|
// - set to 'ort' when building 'umd' format.
|
|
// - set to undefined when building other formats (commonjs/module)
|
|
const exportName = format === 'umd' ? 'ort' : undefined;
|
|
|
|
return {
|
|
target: [target, esVersion],
|
|
entry: resolve('./lib/index.ts'),
|
|
output: {
|
|
path: resolve('./dist'),
|
|
filename,
|
|
library: { name: exportName, type: format },
|
|
},
|
|
resolve: {
|
|
extensions: ['.ts', '.js'],
|
|
extensionAlias: { '.js': ['.ts', '.js'] },
|
|
},
|
|
plugins: [
|
|
new webpack.WatchIgnorePlugin({ paths: [/\.js$/, /\.d\.ts$/] }),
|
|
addCopyrightBannerPlugin(mode, 'common', esVersion),
|
|
],
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.ts$/,
|
|
use: [
|
|
{
|
|
loader: 'ts-loader',
|
|
options: { compilerOptions: { target: esVersion } },
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
mode,
|
|
devtool,
|
|
};
|
|
}
|
|
|
|
export default (env, argv) => {
|
|
return [
|
|
buildConfig({ suffix: '.es5.min.js', target: 'web', esVersion: 'es5' }),
|
|
buildConfig({ suffix: '.min.js' }),
|
|
buildConfig({ mode: 'development', devtool: 'inline-source-map' }),
|
|
buildConfig({
|
|
suffix: '.node.cjs',
|
|
target: 'node',
|
|
format: 'commonjs',
|
|
}),
|
|
];
|
|
};
|