Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ name: Node.js CI

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]

jobs:
build:

runs-on: ubuntu-latest

strategy:
Expand Down Expand Up @@ -46,4 +45,4 @@ jobs:
run: node dist/prefab.cjs

- name: Validate esm version
run: node dist/prefab.mjs
run: PREFAB_SKIP_PEER_DEPENDENCY_CHECK=true node dist/prefab.mjs
16 changes: 1 addition & 15 deletions src/loadConfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as fs from "fs";
import Long from "long";
import type Long from "long";
import type { Config, Configs } from "./proto";
import { maxLong } from "./maxLong";
import { type ApiClient, fetchWithCache } from "./apiClient";
Expand Down Expand Up @@ -112,20 +112,6 @@ const parse = (parsed: Configs): Result => {

const configs = parsed.configs ?? [];

// Check if configs has at least one item and verify if its id is a Long
if (configs.length > 0) {
const firstConfig = configs[0];
if (
firstConfig !== undefined &&
firstConfig !== null &&
!Long.isLong(firstConfig.id)
) {
throw new Error(
'Prefab requires the "long" package to be in your project. See https://www.npmjs.com/package/long'
);
}
}

const defaultContext = extractDefaultContext(parsed.defaultContext);

return {
Expand Down
1 change: 1 addition & 0 deletions src/prefab.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import './verifyPeerDependencies';
import crypto from "crypto";
import Long from "long";
import { apiClient, type ApiClient } from "./apiClient";
Expand Down
11 changes: 11 additions & 0 deletions src/verifyPeerDependencies.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
try {
if (process.env['PREFAB_SKIP_PEER_DEPENDENCY_CHECK'] !== 'true') {
require('long');
}
} catch {
throw new Error(
'Prefab requires the "long" package to be in your project. See https://www.npmjs.com/package/long',
);
}

export {};
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"dist"
],
"compilerOptions": {
"target": "es2018",
"module": "es2015",
"target": "es2020",
"module": "es2022",
"declaration": true,
"outDir": "./dist",
"noEmit": false,
Expand Down