optimize js package folder structure (#7989)

* put generated .js files into dist/ folder

* format code
This commit is contained in:
Yulong Wang 2021-06-08 16:49:06 -07:00 committed by GitHub
parent 47d8977741
commit 1cc896c8ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 44 additions and 38 deletions

View file

@ -1,10 +1,4 @@
node_modules/
types/
dist/
tsconfig.tsbuildinfo
lib/**/*.js
lib/**/*.js.map
*.d.ts

View file

@ -2,6 +2,6 @@
webpack.config.js
tsconfig.json
tsconfig.tsbuildinfo
**/*.tsbuildinfo
*.tgz

View file

@ -23,8 +23,8 @@
"webpack-cli": "^4.7.0"
},
"main": "dist/ort-common.node.js",
"types": "./types/index.d.ts",
"types": "dist/lib/index.d.ts",
"jsdelivr": "dist/ort-common.min.js",
"unpkg": "dist/ort-common.min.js",
"module": "./lib/index.js"
"module": "dist/lib/index.js"
}

View file

@ -1,7 +1,7 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"declarationDir": "./types"
"outDir": "dist/lib",
},
"include": ["lib"]
}

4
js/node/.gitignore vendored
View file

@ -1,12 +1,10 @@
node_modules/
/build/
/bin/
/dist/
/prebuilds/
/types/
/lib/**/*.js
/lib/**/*.js.map
/script/**/*.js
/script/**/*.js.map
/test/**/*.js
/test/**/*.js.map

View file

@ -11,6 +11,6 @@
CMakeLists.txt
tsconfig.json
tsconfig.tsbuildinfo
**/*.tsbuildinfo
*.tgz

View file

@ -21,8 +21,8 @@
"rebuildd": "tsc && node ./script/build --rebuild --config=Debug",
"rebuildr": "tsc && node ./script/build --rebuild --config=RelWithDebInfo",
"install": "prebuild-install -r napi || (tsc && node ./script/build)",
"prepare": "tsc",
"test": "mocha ./test/test-main",
"prepare": "tsc --build script && tsc",
"test": "tsc --build test && mocha ./test/test-main",
"prepack": "node ./script/prepack"
},
"dependencies": {
@ -50,8 +50,8 @@
"typedoc": "^0.20.25",
"typescript": "^4.2.4"
},
"main": "./lib/index.js",
"types": "./types/lib/index.d.ts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"os": [
"win32",
"darwin",

View file

@ -0,0 +1,3 @@
{
"extends": "../../tsconfig.tools.json"
}

View file

@ -1,10 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import {InferenceSession} from 'onnxruntime-common';
import {InferenceSession, Tensor} from 'onnxruntime-common';
import * as path from 'path';
import {Tensor} from '../../lib';
import {SQUEEZENET_INPUT0_DATA, SQUEEZENET_OUTPUT0_DATA, TEST_DATA_ROOT} from '../test-utils';
import {assertTensorEqual} from '../test-utils';

View file

@ -2,10 +2,9 @@
// Licensed under the MIT License.
import assert from 'assert';
import {InferenceSession} from 'onnxruntime-common';
import {InferenceSession, Tensor} from 'onnxruntime-common';
import * as path from 'path';
import {Tensor} from '../../lib';
import {assertDataEqual, TEST_DATA_ROOT} from '../test-utils';

View file

@ -3,6 +3,9 @@
import {NODE_TESTS_ROOT, warmup} from './test-utils';
// require onnxruntime-node.
require('..');
// warmup
//
// for unknown reason, the first call to native InferenceSession::Run() is very slow.

View file

@ -2,10 +2,9 @@
// Licensed under the MIT License.
import * as fs from 'fs-extra';
import {InferenceSession, Tensor} from 'onnxruntime-common';
import * as path from 'path';
import {InferenceSession, Tensor} from '../lib';
import {assertTensorEqual, loadTensorFromFile, shouldSkipModel} from './test-utils';
export function run(testDataFolder: string): void {

View file

@ -5,11 +5,9 @@ import assert from 'assert';
import * as fs from 'fs-extra';
import {jsonc} from 'jsonc';
import * as onnx_proto from 'onnx-proto';
import {Tensor} from 'onnxruntime-common';
import {InferenceSession, Tensor} from 'onnxruntime-common';
import * as path from 'path';
import {binding} from '../lib/binding';
export const TEST_ROOT = __dirname;
export const TEST_DATA_ROOT = path.join(TEST_ROOT, 'testdata');
@ -72,13 +70,16 @@ export function createTestTensor(type: Tensor.Type, lengthOrDims?: number|number
// call the addon directly to make sure DLL is loaded
export function warmup(): void {
// we have test cases to verify correctness in other place, so do no check here.
try {
const session = new binding.InferenceSession();
session.loadModel(path.join(TEST_DATA_ROOT, 'test_types_INT32.pb'), {});
session.run({input: new Tensor(new Float32Array(5), [1, 5])}, {output: null}, {});
} catch (e) {
}
describe('Warmup', async function() {
// eslint-disable-next-line no-invalid-this
this.timeout(0);
// we have test cases to verify correctness in other place, so do no check here.
try {
const session = await InferenceSession.create(path.join(TEST_DATA_ROOT, 'test_types_INT32.pb'));
await session.run({input: new Tensor(new Float32Array(5), [1, 5])}, {output: null}, {});
} catch (e) {
}
});
}
export function assertFloatEqual(

View file

@ -0,0 +1,3 @@
{
"extends": "../../tsconfig.tools.json"
}

View file

@ -3,10 +3,9 @@
import assert from 'assert';
import * as fs from 'fs';
import {InferenceSession} from 'onnxruntime-common';
import {InferenceSession, Tensor, TypedTensor} from 'onnxruntime-common';
import * as path from 'path';
import {Tensor, TypedTensor} from '../../../lib';
import {assertTensorEqual} from '../../test-utils';
const SQUEEZENET_INPUT0_DATA = require(path.join(__dirname, '../../testdata/squeezenet.input0.json'));

View file

@ -2,7 +2,7 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"module": "CommonJS",
"declarationDir": "./types"
"outDir": "dist"
},
"include": ["lib", "script", "test"]
"include": ["lib"]
}

8
js/tsconfig.tools.json Normal file
View file

@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "CommonJS",
"declaration": false,
"sourceMap": false
}
}