зеркало из https://github.com/microsoft/ml4f.git
also build esm modules; see #19
This commit is contained in:
Родитель
052f73bcb1
Коммит
f21eb75adc
|
@ -11,3 +11,4 @@ c/*.dump
|
|||
c/*.hex
|
||||
c/*.bin
|
||||
tmp
|
||||
*.tgz
|
||||
|
|
12
build.js
12
build.js
|
@ -57,8 +57,9 @@ function runTSC(args) {
|
|||
}
|
||||
|
||||
const files = {
|
||||
"built/ml4f.js": "src/main.ts",
|
||||
"built/ml4f.cjs": "src/main.ts",
|
||||
"built/ml4f.js": "src/ml4f.ts",
|
||||
"built/ml4f.cjs": "src/ml4f.ts",
|
||||
"built/ml4f.mjs": "src/ml4f.ts",
|
||||
"built/pxtml4f.js": "pxt/extension.ts",
|
||||
"built/pxtml4f.cjs": "pxt/extension.ts",
|
||||
"built/cli.cjs": "cli/src/cli.ts",
|
||||
|
@ -68,18 +69,21 @@ async function main() {
|
|||
try {
|
||||
for (const outfile of Object.keys(files)) {
|
||||
const src = files[outfile]
|
||||
const basename = outfile.replace(/.*\//, "").replace(/\..*/, "")
|
||||
const cjs = outfile.endsWith(".cjs")
|
||||
const mjs = outfile.endsWith(".mjs")
|
||||
const iife = !cjs && !mjs
|
||||
await esbuild.build({
|
||||
entryPoints: [src],
|
||||
bundle: true,
|
||||
sourcemap: true,
|
||||
outfile,
|
||||
logLevel: "warning",
|
||||
external: ["@tensorflow/tfjs", "commander"],
|
||||
external: iife ? [] : ["@tensorflow/tfjs", "commander"],
|
||||
platform: cjs ? "node" : "browser",
|
||||
target: "es2019",
|
||||
format: mjs ? "esm" : cjs ? "cjs" : "iife",
|
||||
globalName: iife ? basename : undefined,
|
||||
watch
|
||||
})
|
||||
}
|
||||
|
@ -88,7 +92,7 @@ async function main() {
|
|||
await runTSC(["-b", ".", "pxt", "cli"])
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
|
|
|
@ -11,7 +11,7 @@ import {
|
|||
Options, runModel, sampleModel, testAllModels,
|
||||
testFloatConv,
|
||||
toCSource
|
||||
} from '../../src/main'
|
||||
} from '../../src/ml4f'
|
||||
|
||||
interface CmdOptions {
|
||||
debug?: boolean
|
||||
|
|
|
@ -7,14 +7,9 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>ML4F</title>
|
||||
|
||||
<!-- Import TensorFlow.js -->
|
||||
<script src="node_modules/@tensorflow/tfjs/dist/tf.es2017.js"></script>
|
||||
<!-- Import tfjs-vis -->
|
||||
<script src="node_modules/@tensorflow/tfjs-vis/dist/tfjs-vis.umd.min.js"></script>
|
||||
|
||||
|
||||
<!-- Import the main script file -->
|
||||
<script src="built/ml4f.js" type="module"></script>
|
||||
<script src="built/ml4f.js"></script>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
"types": "./built/ml4f.d.ts",
|
||||
"main": "./built/ml4f.cjs",
|
||||
"browser": "./built/ml4f.js",
|
||||
"module": "./built/ml4f.mjs",
|
||||
"files": [
|
||||
"built/ml4f.*js",
|
||||
"built/pxtml4f.*js",
|
||||
|
|
|
@ -7,9 +7,7 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>ML4F</title>
|
||||
|
||||
<script src="../node_modules/@tensorflow/tfjs/dist/tf.es2017.js"></script>
|
||||
<script src="../built/ml4f.js" type="module"></script>
|
||||
<script src="../built/pxtml4f.js" type="module"></script>
|
||||
<script src="../built/pxtml4f.js"></script>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
"noImplicitReturns": true,
|
||||
"outDir": "built",
|
||||
"newLine": "LF",
|
||||
"noEmit": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"outFile": "built/ml4f",
|
||||
"typeRoots": [
|
||||
"node_modules/@types"
|
||||
]
|
||||
|
|
Загрузка…
Ссылка в новой задаче