@tabula/forge
Advanced tools
Changelog
1.0.0
#14 b0d7f4c
Thanks @demiazz! - merge build
and watch
commands.
The watch
command has been replaced with -w,--watch
option. Also, we replace platform command with -t,--target
option.
You should change:
forge watch node
to the following code:
forge build --target node --watch
#14 b0d7f4c
Thanks @demiazz! - add support of configuration file
You can use configuration file. We're looking for:
forge
property in the package.json
;.forgerc
file;.forgerc
file with .json
, .yaml
, .yml
, .js
, .mjs
or .cjs
forge.config.js
, forge.config.mjs
, or forge.config.cjs
file.Look at example of JSON configuration:
{
"$schema": "https://github.com/ReTable/forge/blob/main/schemas/forgerc.json",
"target": "node",
"entry": "index",
"check": true,
"typings": true,
"postBuild": "touch lib/meta.js",
"build": {
"production": true
},
"watch": {
"production": false,
"storybook": true
}
}
#14 b0d7f4c
Thanks @demiazz! - add support of post build hooks
You can use one or more post build hooks:
forge build --target node --post-build "touch lib/index.js" --post-build "touch index.d.ts":"typings"
Changelog
0.3.0
#12 0813828
Thanks @demiazz! - add support of multiple entries
You can use --entry
option to define entry points.
The --entry
option has the following syntax: --entry <in>[:<out>]
. You can use this option more than one time to
define multiple entries.
By default, the forge
always searches <packageRoot>/src/index.tsx
or <packageRoot>/src/index.ts
entry point, and
always bundles it to the <packageRoot>/lib/index.js
.
The following command:
$ forge build browser
is equivalent to this command:
$ forge build browser --entry index
We allow to define input module as path to file or as path to module. A given path will be automatically prepended by
./src/
path before it will be transferred to the esbuild
.
If you provide a module path, then the forge
will search entry point in different ways.
For example, look at the next command:
$ forge build browser --entry nodes
The forge
will search entry point in the following order:
<packageRoot>/src/nodes.tsx
<packageRoot>/src/nodes.ts
<packageRoot>/src/nodes/index.tsx
<packageRoot>/src/nodes/index.ts
By default, the forge
uses module path relative to the <packageRoot>/src
directory.
For example, look at this command:
$ forge build browser --entry nodes
The forge
create <packageRoot>/lib/nodes.js
bundle independent of entry point (nodes.ts
or nodes/index.ts
).
But if you call it in the following style:
$ forge build browser --entry nodes/index
Then the <packageRoot>/lib/nodes/index.js
will be created.
Also, don't provide .js
extension for output entry. It will be added automatically.
But even if you provide it, then we automatically remove it before calling of esbuild
to prevent creating a file with
doubled .js
extension.
Support of multiple entries enables code splitting feature to share the code inside a bundled library.
It creates ESM modules with shared code and uses them in bundles.
Each JS bundle will automatically import own CSS bundle in beginning of file if a CSS bundle is exists.
IMPORTANT: This feature not working with CSS. Yes, your imports from CSS modules or vanilla-extract
will be
shared, but own CSS bundle will be created for each JS bundle, even they have a similar styles inside. Hashed classes
will be identical in all CSS bundles too. Keep it in mind.