Skip to content

Commit

Permalink
[WIP] js-module
Browse files Browse the repository at this point in the history
  • Loading branch information
aricart committed May 26, 2023
1 parent feb6db8 commit 1bb730c
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ certs/
cjs-build/
cjs-wst/
nats-base-client/
jetstream/

nats-server
nats.js
Expand Down
5 changes: 5 additions & 0 deletions bin/cjs-fix-imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ for (const fn of files) {
"../nats-base-client",
);

mod = mod.replace(
/(https:\/\/raw.githubusercontent.com\/nats-io\/nats.deno\/\S+\/jetstream)/gim,
"../jetstream",
);

// some of the imports are references to external projects
// that in node we resolve with requires - if we encounter one that
// the script is not configured for, the build fails
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@
"install-certs": "env CAROOT=./certs mkcert -cert-file ./certs/cert.pem -key-file ./certs/key.pem -install localhost 127.0.0.1 ::1",
"install-ns": "shx mkdir -p ./.deps && cd ./.deps && git clone --branch=main https://github.com/nats-io/nats-server.git && cd nats-server && go build && shx mv nats-server ../../",
"prepack": "npm run build",
"clean": "shx rm -Rf ./esm/nats.js ./lib ./.deps ./nats-base-client ./wst",
"clean": "shx rm -Rf ./esm/nats.js ./lib ./.deps ./nats-base-client ./jetstream ./wst",
"build": "npm run clean && npm run check-imports && npm run check-package && npm run build-cjs && npm run build-esm",
"build-cjs": "npm run stage && npm run cjs-nbc && npm run cjs-wst && shx rm -Rf ./deps/ && tsc && shx rm -Rf ./wst && shx mv ./lib/wst ./lib/src && rm -Rf ./nats-base-client",
"build-cjs": "npm run stage && npm run cjs-nbc && npm run cjs-jetstream && npm run cjs-wst && shx rm -Rf ./deps/ && tsc && shx rm -Rf ./wst && shx mv ./lib/wst ./lib/src && rm -Rf ./nats-base-client ./jetstream",
"build-esm": "deno run --allow-all --unstable --reload src/mod.ts && deno bundle --log-level info --unstable src/mod.ts ./esm/nats.js",
"stage": "npm run clone-nbc",
"cjs-nbc": "deno run --allow-all ./bin/cjs-fix-imports.ts -o nats-base-client/ ./.deps/nats.deno/nats-base-client/",
"cjs-nbc": "deno run --allow-all ./bin/cjs-fix-imports.ts -o nats-base-client/ ./.deps/nats.deno/nats-base-client",
"cjs-jetstream": "deno run --allow-all ./bin/cjs-fix-imports.ts -o jetstream/ ./.deps/nats.deno/jetstream/",
"cjs-wst": "deno run --allow-all ./bin/cjs-fix-imports.ts -o wst/ ./src",
"clone-nbc": "deno run --allow-all bin/clone-nd.ts",
"ava": "nyc ava --verbose -T 60000",
Expand Down
2 changes: 1 addition & 1 deletion src/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
setTransportFactory,
Transport,
TransportFactory,
} from "https://raw.githubusercontent.com/nats-io/nats.deno/dev/nats-base-client/internal_mod.ts";
} from "https://raw.githubusercontent.com/nats-io/nats.deno/js-module/nats-base-client/internal_mod.ts";

import { WsTransport } from "./ws_transport.ts";

Expand Down
3 changes: 2 additions & 1 deletion src/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from "https://raw.githubusercontent.com/nats-io/nats.deno/dev/nats-base-client/mod.ts";
export * from "https://raw.githubusercontent.com/nats-io/nats.deno/js-module/nats-base-client/mod.ts";
export * from "https://raw.githubusercontent.com/nats-io/nats.deno/js-module/jetstream/mod.ts";
export { connect } from "./connect.ts";
2 changes: 1 addition & 1 deletion src/nats-base-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
* limitations under the License.
*/
// this import here to drive the build system
export * from "https://raw.githubusercontent.com/nats-io/nats.deno/dev/nats-base-client/internal_mod.ts";
export * from "https://raw.githubusercontent.com/nats-io/nats.deno/js-module/nats-base-client/internal_mod.ts";
4 changes: 2 additions & 2 deletions src/ws_transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import type {
Server,
ServerInfo,
Transport,
} from "https://raw.githubusercontent.com/nats-io/nats.deno/dev/nats-base-client/internal_mod.ts";
} from "https://raw.githubusercontent.com/nats-io/nats.deno/js-module/nats-base-client/internal_mod.ts";
import {
checkOptions,
DataBuffer,
Expand All @@ -30,7 +30,7 @@ import {
INFO,
NatsError,
render,
} from "https://raw.githubusercontent.com/nats-io/nats.deno/dev/nats-base-client/internal_mod.ts";
} from "https://raw.githubusercontent.com/nats-io/nats.deno/js-module/nats-base-client/internal_mod.ts";

const VERSION = "1.16.0-1";
const LANG = "nats.ws";
Expand Down
3 changes: 1 addition & 2 deletions test/jetstream.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
* limitations under the License.
*/
const test = require("ava");
const { delay } = require("../lib/nats-base-client/internal_mod");
const { delay, DataBuffer } = require("../lib/nats-base-client/internal_mod");
const { connect, Empty, consumerOpts, AckPolicy, headers, StringCodec } =
require(
"./index",
);
const { NatsServer, wsConfig } = require("./helpers/launcher");
const { jetstreamServerConf } = require("./helpers/jsutil");
const { DataBuffer } = require("../lib/nats-base-client/databuffer");
const { setTimeout } = require("timers");

test("jetstream - jsm", async (t) => {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"allowJs": true
},
"include": [
"wst"
"wst",
],
"exclude": [
"src/**/*",
Expand Down

0 comments on commit 1bb730c

Please sign in to comment.