forked from microsoft/onnxruntime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[js/common] allow import onnxruntime-common as ESM and CJS (microsoft…
…#15772) ### Description allow import onnxruntime-common as ESM and CJS.
- Loading branch information
Showing
24 changed files
with
222 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/.vscode/ | ||
|
||
build.js | ||
webpack.config.js | ||
typedoc.json | ||
tsconfig.json | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
'use strict'; | ||
|
||
import {execSync} from 'node:child_process'; | ||
import {writeFileSync} from 'node:fs'; | ||
import {resolve, dirname} from 'node:path'; | ||
import {fileURLToPath} from 'node:url'; | ||
|
||
const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
|
||
// build the following folders: | ||
// - dist/cjs | ||
// - dist/esm | ||
execSync('npm run build:cjs', {shell: true, stdio: 'inherit', cwd: __dirname}); | ||
execSync('npm run build:esm', {shell: true, stdio: 'inherit', cwd: __dirname}); | ||
|
||
// generate package.json files under each of the dist folders for commonJS and ESModule | ||
// this trick allows typescript to import this package as different module type | ||
// see also: https://evertpot.com/universal-commonjs-esm-typescript-packages/ | ||
writeFileSync(resolve(__dirname, './dist/cjs', 'package.json'), '{"type": "commonjs"}'); | ||
writeFileSync(resolve(__dirname, './dist/esm', 'package.json'), '{"type": "module"}'); | ||
|
||
// launch webpack to generate bundles | ||
execSync('npm run build:bundles', {shell: true, stdio: 'inherit', cwd: __dirname}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,32 @@ | ||
{ | ||
"license": "MIT", | ||
"unpkg": "dist/ort-common.min.js", | ||
"type": "module", | ||
"name": "onnxruntime-common", | ||
"version": "1.16.0", | ||
"repository": { | ||
"url": "https://github.com/Microsoft/onnxruntime.git", | ||
"type": "git" | ||
}, | ||
"author": "fs-eire", | ||
"module": "dist/lib/index.js", | ||
"version": "1.16.0", | ||
"jsdelivr": "dist/ort-common.min.js", | ||
"scripts": { | ||
"prepare": "tsc && webpack" | ||
"build:cjs": "npx tsc --module commonjs --outDir ./dist/cjs", | ||
"build:esm": "npx tsc", | ||
"build:bundles": "webpack", | ||
"build": "node ./build.js", | ||
"prepare": "npm run build" | ||
}, | ||
"devDependencies": { | ||
"typedoc": "^0.23.22" | ||
}, | ||
"main": "dist/cjs/index.js", | ||
"exports": { | ||
"require": "./dist/cjs/index.js", | ||
"import": "./dist/esm/index.js" | ||
}, | ||
"keywords": [ | ||
"ONNX", | ||
"ONNXRuntime", | ||
"ONNX Runtime" | ||
], | ||
"devDependencies": { | ||
"typedoc": "^0.23.22" | ||
}, | ||
"main": "dist/ort-common.node.js", | ||
"types": "dist/lib/index.d.ts", | ||
"description": "ONNXRuntime JavaScript API library" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.