Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22398396
esbuild.cjs
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
esbuild.cjs
View Options
const
{
build
}
=
require
(
"esbuild"
);
const
glob
=
require
(
"tiny-glob"
);
const
{
promises
:
fs
}
=
require
(
"node:fs"
);
const
{
extname
,
resolve
,
relative
}
=
require
(
"node:path"
);
const
watch
=
process
.
argv
.
at
(
-
1
)
===
"--watch"
;
// plugin that rewrites the import paths so in typescript we can use
//
// import smth from src/index.ts
//
// instead of providing relative paths
const
handle_absolute_paths
=
(
project_dir
)
=>
({
name
:
"sealgen-rewrite-asset-imports"
,
setup
(
build
)
{
build
.
onLoad
({
filter
:
/\.tsx?$/
},
async
(
args
)
=>
{
let
contents
=
await
fs
.
readFile
(
args
.
path
,
"utf8"
);
const
regex_import
=
new
RegExp
(
`^import ([^ ]+, )?(\\w+|{[^}]+}) from "([^"]+)";`
,
"gm"
);
contents
=
contents
.
replaceAll
(
regex_import
,
(
line
)
=>
{
const
replaced
=
line
.
replace
(
`"src/`
,
`"`
+
relative
(
args
.
path
,
resolve
(
project_dir
,
"./lib/src"
))
+
"/"
);
return
replaced
;
});
return
{
contents
,
loader
:
extname
(
args
.
path
)
===
".tsx"
?
"tsx"
:
"ts"
,
};
});
},
});
(
async
()
=>
{
let
entryPoints
=
Object
.
fromEntries
(
(
await
glob
(
"./src/**/*.ts"
)).
map
((
e
)
=>
[
e
.
replace
(
/\.ts$/
,
""
),
e
])
);
build
({
entryPoints
,
sourcemap
:
true
,
outdir
:
"./lib"
,
logLevel
:
"info"
,
platform
:
"node"
,
watch
,
target
:
"node16"
,
format
:
"esm"
,
plugins
:
[
handle_absolute_paths
(
__dirname
)],
});
})();
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Fri, Nov 27, 17:22 (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1191672
Default Alt Text
esbuild.cjs (1 KB)
Attached To
Mode
rMONACO monaco-wrapper
Attached
Detach File
Event Timeline