forked from svrjs/svrjs
Make the build script transpile the utilities
This commit is contained in:
parent
2a9b47a318
commit
c4c207cd98
2 changed files with 27 additions and 19 deletions
2
NOTES
2
NOTES
|
@ -1,2 +0,0 @@
|
||||||
In the src folder, you can use any version - it will be transpiled to ES2017 by esbuild.
|
|
||||||
But in the utils folder, you have to use at most ES2017, because it is not transpiled.
|
|
|
@ -124,19 +124,12 @@ fs.writeFileSync(__dirname + "/generatedAssets/licenses/index.html", licensesPag
|
||||||
|
|
||||||
// Bundle the source and copy the assets using esbuild and esbuild-plugin-copy
|
// Bundle the source and copy the assets using esbuild and esbuild-plugin-copy
|
||||||
esbuild.build({
|
esbuild.build({
|
||||||
entryPoints: ["src/index.js"], // Your entry file
|
entryPoints: ["src/index.js"],
|
||||||
bundle: true,
|
bundle: true,
|
||||||
outfile: "dist/svr.js", // Output file
|
outfile: "dist/svr.js",
|
||||||
platform: "node",
|
platform: "node",
|
||||||
target: "es2017",
|
target: "es2017",
|
||||||
plugins: [
|
plugins: [
|
||||||
esbuildCopyPlugin.copy({
|
|
||||||
resolveFrom: __dirname,
|
|
||||||
assets: {
|
|
||||||
from: ["./utils/**/*"],
|
|
||||||
to: ["./dist"],
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
esbuildCopyPlugin.copy({
|
esbuildCopyPlugin.copy({
|
||||||
resolveFrom: __dirname,
|
resolveFrom: __dirname,
|
||||||
assets: {
|
assets: {
|
||||||
|
@ -155,6 +148,20 @@ esbuild.build({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
|
}).then(() => {
|
||||||
|
const utilFilesAndDirectories = fs.existsSync(__dirname + "/utils") ? fs.readdirSync(__dirname + "/utils") : [];
|
||||||
|
const utilFiles = [];
|
||||||
|
utilFilesAndDirectories.forEach((entry) => {
|
||||||
|
if (fs.statSync(__dirname + "/utils/" + entry).isFile()) utilFiles.push(entry);
|
||||||
|
})
|
||||||
|
|
||||||
|
// Transpile utilities using esbuild
|
||||||
|
esbuild.build({
|
||||||
|
entryPoints: [utilFiles.map((filename) => "utils/" + filename)],
|
||||||
|
bundle: false,
|
||||||
|
outdir: "dist",
|
||||||
|
platform: "node",
|
||||||
|
target: "es2017",
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
const archiveName = "svr.js." + version.toLowerCase().replace(/[^0-9a-z]+/g,".") + ".zip";
|
const archiveName = "svr.js." + version.toLowerCase().replace(/[^0-9a-z]+/g,".") + ".zip";
|
||||||
const output = fs.createWriteStream(__dirname + "/out/" + archiveName);
|
const output = fs.createWriteStream(__dirname + "/out/" + archiveName);
|
||||||
|
@ -166,4 +173,7 @@ esbuild.build({
|
||||||
archive.finalize();
|
archive.finalize();
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
throw err;
|
throw err;
|
||||||
|
})
|
||||||
|
}).catch((err) => {
|
||||||
|
throw err;
|
||||||
});
|
});
|
||||||
|
|
Reference in a new issue