Skip to content

Commit 5e20bbd

Browse files
committed
feat: Convert to monorepo
Publish each package to npm as a separate module. Signed-off-by: Gordon Smith <[email protected]>
1 parent b0d8c38 commit 5e20bbd

File tree

135 files changed

+12296
-2586
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+12296
-2586
lines changed

.gitignore

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
/.nyc_output
1+
.nyc_output/
22
/.vscode/c_cpp_properties.json
33
/.vscode/ipch
4-
/bin
5-
/build
4+
.nx/
5+
bin/
6+
build/
67
/coverage
7-
/dist
8-
/dist-test
8+
dist/
9+
dist-test/
910
/docs/.vitepress/cache
1011
/docs/.vitepress/dist
1112
/docs/classes
@@ -15,14 +16,17 @@
1516
/docs/README.md
1617
/emsdk*
1718
/lib-*
18-
/node_modules
19+
node_modules/
1920
/rust
2021
/third-party
2122
/src-ts/*.wasm.ts
2223
/tmp
23-
/types
24+
types/
2425
/wasi-sdk*
2526
/wit-bindgen
2627
/vcpkg
2728
.coveralls.yml
2829
*.tsbuildinfo
30+
31+
.nx/cache
32+
.nx/workspace-data

.nycrc

Lines changed: 0 additions & 7 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,8 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
7979
set(PACK_MODE "-d")
8080
endif ()
8181

82-
function(packWasm targetID)
83-
add_custom_target(sfx-${targetID} ALL
84-
COMMAND node ./utils/sfx-wasm.js ${PACK_MODE} ${CMAKE_CURRENT_BINARY_DIR}/${targetID}.wasm > ${REPO_DIR}/build/${targetID}.wasm.js
85-
WORKING_DIRECTORY ${REPO_DIR}
86-
COMMENT "SFX Wasm ${targetID}"
87-
)
88-
89-
add_dependencies(sfx-${targetID} ${targetID} base91lib zstdlib)
90-
endfunction ()
91-
9282
add_subdirectory(src-cpp)
83+
add_subdirectory(packages/base91/src-cpp)
84+
add_subdirectory(packages/expat/src-cpp)
85+
add_subdirectory(packages/graphviz/src-cpp)
86+
add_subdirectory(packages/zstd/src-cpp)

CMakePresets.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"hidden": true,
77
"generator": "Ninja",
88
"cacheVariables": {
9-
"REPO_DIR": "${sourceDir}",
109
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake"
1110
}
1211
},

esbuild.mjs

Lines changed: 11 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import * as process from "process";
22
import { readFileSync } from "fs";
33
import * as esbuild from "esbuild";
4+
import { umdWrapper } from "esbuild-plugin-umd-wrapper";
5+
import { rebuildLogger, sfxWasm } from "@hpcc-js/esbuild-plugins";
46
import yargs from "yargs";
57
import { hideBin } from "yargs/helpers";
68

@@ -33,73 +35,30 @@ const isDevelopment = argv.mode === "development";
3335
const isProduction = !isDevelopment;
3436
const isWatch = argv.watch;
3537

36-
// plugins ---
37-
const excludeSourceMapPlugin = ({ filter }) => ({
38-
name: "excludeSourceMapPlugin",
39-
40-
setup(build) {
41-
build.onLoad({ filter }, (args) => {
42-
return {
43-
contents:
44-
readFileSync(args.path, "utf8") +
45-
"\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIiJdLCJtYXBwaW5ncyI6IkEifQ==",
46-
loader: "default",
47-
};
48-
});
49-
},
50-
});
51-
52-
const esbuildProblemMatcherPlugin = ({ filter }) => ({
53-
name: "esbuild-problem-matcher",
54-
55-
setup(build) {
56-
build.onStart(() => {
57-
console.log("[watch] build started");
58-
});
59-
build.onEnd((result) => {
60-
result.errors.forEach(({ text, location }) => {
61-
console.error(`✘ [ERROR] ${text}`);
62-
console.error(` ${location.file}:${location.line}:${location.column}:`);
63-
});
64-
console.log("[watch] build finished");
65-
});
66-
},
67-
});
68-
69-
function rebuildNotify(config) {
70-
return {
71-
name: "rebuild-notify",
72-
73-
setup(build) {
74-
build.onEnd(result => {
75-
console.log(`Built ${config.outfile}`);
76-
});
77-
},
78-
};
79-
}
80-
8138
// helpers ---
8239
function build(config) {
8340
isDevelopment && console.log("Start: ", config.entryPoints[0], config.outfile);
8441
return esbuild.build({
8542
...config,
86-
sourcemap: "external",
43+
sourcemap: "linked",
8744
plugins: [
8845
...(config.plugins ?? []),
46+
sfxWasm()
8947
]
9048
}).then(() => {
9149
isDevelopment && console.log("Stop: ", config.entryPoints[0], config.outfile);
9250
});
9351
}
9452

9553
async function watch(config) {
96-
await esbuild.build(config);
54+
await build(config);
9755
return esbuild.context({
9856
...config,
99-
sourcemap: "linked",
57+
sourcemap: "external",
10058
plugins: [
10159
...(config.plugins ?? []),
102-
rebuildNotify(config),
60+
rebuildLogger(config),
61+
sfxWasm()
10362
]
10463
}).then(ctx => {
10564
return ctx.watch();
@@ -120,14 +79,15 @@ function browserTpl(input, output, format, globalName = "", external = []) {
12079
globalName,
12180
bundle: true,
12281
minify: isProduction,
123-
external
82+
external,
83+
plugins: format === "umd" ? [umdWrapper()] : []
12484
});
12585
}
12686

12787
function browserBoth(input, output, globalName = undefined, external = []) {
12888
return Promise.all([
12989
browserTpl(input, output, "esm", globalName, external),
130-
browserTpl(input, output, "iife", globalName, external)
90+
browserTpl(input, output, "umd", globalName, external)
13191
]);
13292
}
13393

eslint.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ export default [
2020
rules: {
2121
"@typescript-eslint/no-explicit-any": "off",
2222
"@typescript-eslint/no-unused-expressions": "off",
23+
"@typescript-eslint/no-namespace": "off",
24+
"@typescript-eslint/no-unused-vars": [
25+
"error", // or "error"
26+
{
27+
"argsIgnorePattern": "^_",
28+
// "varsIgnorePattern": "^_",
29+
// "caughtErrorsIgnorePattern": "^_"
30+
}
31+
]
2332
}
2433
},
2534
];

lerna.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
3+
"useNx": true,
4+
"command": {
5+
"version": {
6+
"conventionalCommits": true,
7+
"gitRemote": "upstream",
8+
"ignoreChanges": [
9+
"__package__.ts",
10+
"*.md"
11+
],
12+
"allowBranch": "trunk"
13+
},
14+
"publish": {}
15+
},
16+
"version": "independent"
17+
}

0 commit comments

Comments
 (0)