-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- replace import `assert` keyword with `with`, see #492 - upgrade azure package to support node v22
- Loading branch information
Roy Razon
committed
May 18, 2024
1 parent
14e5490
commit 8c38a29
Showing
4 changed files
with
88 additions
and
25 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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import * as esbuild from 'esbuild'; | ||
|
||
const ESM_REQUIRE_SHIM = ` | ||
await (async () => { | ||
const { dirname } = await import("path"); | ||
const { fileURLToPath } = await import("url"); | ||
/** | ||
* Shim entry-point related paths. | ||
*/ | ||
if (typeof globalThis.__filename === "undefined") { | ||
globalThis.__filename = fileURLToPath(import.meta.url); | ||
} | ||
if (typeof globalThis.__dirname === "undefined") { | ||
globalThis.__dirname = dirname(globalThis.__filename); | ||
} | ||
/** | ||
* Shim require if needed. | ||
*/ | ||
if (typeof globalThis.require === "undefined") { | ||
const { default: module } = await import("module"); | ||
globalThis.require = module.createRequire(import.meta.url); | ||
} | ||
})(); | ||
`; | ||
|
||
await esbuild.build({ | ||
entryPoints: ['./src/index.ts'], | ||
bundle: true, | ||
treeShaking: true, | ||
outdir: './dist', | ||
// outExtension: { '.js': '.mjs' }, | ||
platform: 'node', | ||
target: 'es2022', | ||
format: 'esm', | ||
loader: { | ||
'.node': 'file', | ||
}, | ||
sourcemap: true, | ||
banner: { js: ESM_REQUIRE_SHIM }, | ||
plugins: [], | ||
// external: ['shelljs'], | ||
packages: 'external', | ||
supported: { | ||
'import-assertions': false, | ||
} | ||
}) | ||
|
||
// const readPackageJson = async dir => JSON.parse(await fs.readFile(`${dir}/package.json`, 'utf-8')) | ||
// const packageName = async dir => (await readPackageJson(dir)).name | ||
|
||
// const copyStatic = async () => { | ||
// const statics = await Promise.all( | ||
// (await glob('../*/static')).map(async dir => [dir, await packageName(path.dirname(dir))]) | ||
// ) | ||
// console.log(statics) | ||
// await Promise.all( | ||
// statics.map(async ([dir, pkg]) => fs.cp(`${dir}/`, `./dist/static/${pkg}/`, { recursive: true })) | ||
// ) | ||
// } | ||
|
||
// await copyStatic() | ||
|
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