Skip to content

Commit

Permalink
refactor: all ESM and use @rdfjs/environment
Browse files Browse the repository at this point in the history
  • Loading branch information
tpluscode committed Jun 29, 2023
1 parent 84d3b85 commit f48a8a4
Show file tree
Hide file tree
Showing 125 changed files with 9,124 additions and 11,051 deletions.
12 changes: 12 additions & 0 deletions .changeset/cool-donkeys-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"alcaeus": major
---

Convert to ESM-only. Other changes include:

1. `isomorphic-fetch` and `isomorhpic-form-data` are removed as dependencies. They should be loaded by consumer s if necessary
2. Removed `./web` and `./node` modules
```diff
-import { Hydra } from 'alcaeus/web'
+import { Hydra } from 'alcaeus'
```
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ indent_style = space
indent_size = 2

[*.ts]
indent_size = 4
indent_size = 2

[*.conf*.js]
indent_size = 4
indent_size = 2
42 changes: 6 additions & 36 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,19 @@
"@tpluscode"
],
"parserOptions": {
"project": "./tsconfig.eslint.json",
"extraFileExtensions": [".mjs"]
"project": "./tsconfig.json"
},
"env": {
"browser": true,
"jest/globals": true
},
"plugins": [
"jest"
],
"rules": {
"@typescript-eslint/indent": ["error", 4],
"import/no-extraneous-dependencies": ["error", {"devDependencies": ["tests/**"]}]
"mocha": true
},
"overrides": [
{
"extends": [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings"
"files": [
"test/**"
],
"files": ["**/*.mjs"],
"rules": {
"no-void": "off",
"no-func-assign": "off",
"prefer-const": "off",
"@typescript-eslint/no-empty-function": "off"
},
"settings": {
"import/extensions": [
".js",
".mjs"
]
}
},
{
"files": ["tests/**/*.ts"],
"rules": {
"@typescript-eslint/no-object-literal-type-assertion": "off",
"no-prototype-builtins": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/explicit-function-return-type": "off"
"no-unused-expressions": "off",
"import/no-extraneous-dependencies": "off"
}
}
]
Expand Down
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
40 changes: 0 additions & 40 deletions babel.config.json

This file was deleted.

5 changes: 0 additions & 5 deletions husky.config.js

This file was deleted.

11 changes: 0 additions & 11 deletions jest.config.js

This file was deleted.

136 changes: 61 additions & 75 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,20 @@
"description": "Hydra Core hypermedia-aware client library",
"main": "index.js",
"types": "index.d.ts",
"module": "index.mjs",
"module": "index.js",
"type": "module",
"exports": {
".": {
"require": "./index.js",
"import": "./index.mjs"
},
"./web": {
"require": "./web.js",
"import": "./web.mjs"
},
"./node": {
"require": "./node.js",
"import": "./node.mjs"
}
".": "./index.js",
"./web": "./web.js",
"./node": "./node.js"
},
"directories": {
"test": "tests"
},
"scripts": {
"test": "jest",
"build": "run-s build:esm build:cjs",
"build:cjs": "tsc",
"build:esm": "BABEL_ENV=modules babel src --out-dir . --extensions .ts --out-file-extension .mjs",
"prepare": "husky install",
"test": "mocha",
"build": "tsc",
"docs": "docsify serve docs",
"lint": "eslint . --ext .ts --quiet",
"prepack": "npm run build",
Expand All @@ -51,92 +42,87 @@
},
"homepage": "https://alcaeus.hydra.how",
"dependencies": {
"@rdf-esm/data-model": "^0.5.3",
"@rdf-esm/formats-common": "^0.5.6",
"@rdf-esm/sink-map": "^0.5.0",
"@rdf-esm/term-map": "^0.5.0",
"@rdf-esm/term-set": "^0.5.0",
"@rdfine/hydra": "^0.8.4",
"@rdfine/rdf": "^0.5.7",
"@rdfjs/dataset": "^1.1.1",
"@rdfjs/formats-common": "^2.2.0",
"@rdfine/hydra": "^0.9.0",
"@rdfine/rdf": "^0.6.0",
"@rdfjs/environment": "^0.1.2",
"@rdfjs/formats-common": "^3.1.0",
"@rdfjs/types": "*",
"@tpluscode/rdf-ns-builders": "^2.0.0",
"@tpluscode/rdfine": "^0.5.39",
"@tpluscode/rdf-ns-builders": "^4.0.0",
"@tpluscode/rdfine": "^0.6.0",
"@types/parse-link-header": "^2.0.0",
"clownface": "^1.1.0",
"isomorphic-fetch": "^3.0.0",
"isomorphic-form-data": "^2.0.0",
"parse-link-header": "^2.0.0",
"rdf-dataset-ext": "^1.0.0",
"rdf-literal": "^1.3.0",
"readable-stream": "^3.6.0"
"readable-stream": ">=3.6.0"
},
"devDependencies": {
"@babel/cli": "^7.14.5",
"@babel/helper-create-class-features-plugin": "^7.14.6",
"@babel/plugin-proposal-class-properties": "^7.14.5",
"@babel/plugin-proposal-decorators": "^7.14.5",
"@babel/plugin-proposal-object-rest-spread": "^7.14.5",
"@babel/plugin-proposal-optional-chaining": "^7.14.5",
"@babel/preset-env": "^7.14.5",
"@babel/preset-typescript": "^7.14.5",
"@changesets/cli": "^2.16.0",
"@rdfjs/data-model": "^1.2",
"@rdfjs/namespace": "^1.1.0",
"@rdfjs/parser-jsonld": "^1.2.0",
"@rdfjs/parser-n3": "^1.1.3",
"@rdfjs/sink-map": "^1.0.1",
"@tpluscode/eslint-config": "^0.3.0",
"@tpluscode/rdf-string": "^0.2.26",
"@rdfjs/parser-jsonld": "^2.1.0",
"@rdfjs/parser-n3": "^2.0.1",
"@rdfjs/sink-map": "^2.0.0",
"@tpluscode/eslint-config": "0.4.3",
"@tpluscode/rdf-string": "^1.0.3",
"@types/chai": "^4.3.5",
"@types/chai-as-promised": "^7.1.5",
"@types/clownface": "^1.0.3",
"@types/isomorphic-fetch": "0.0.35",
"@types/jest": "^26.0.15",
"@types/mocha": "^10.0.1",
"@types/rdf-dataset-ext": "^1.0.1",
"@types/rdf-ext": "^1.3.7",
"@types/rdfjs__dataset": "^1",
"@types/rdfjs__formats-common": "^2.0.0",
"@types/rdfjs__namespace": "^1.1.3",
"@types/rdfjs__parser-jsonld": "^1.2.2",
"@types/rdfjs__parser-n3": "^1.1.2",
"@types/rdfjs__term-map": "^1.0.1",
"@types/rdfjs__term-set": "^1.0.0",
"@types/readable-stream": "^2.3.5",
"@types/rdf-ext": "^2.2.0",
"@types/rdfjs__environment": "^0.1.4",
"@types/rdfjs__formats-common": "^3.1.0",
"@types/rdfjs__parser-n3": "^2.0.1",
"@types/rdfjs__sink-map": "^2.0.1",
"@types/readable-stream": "^2.3.15",
"@types/sinon": "^10.0.11",
"@typescript-eslint/eslint-plugin": "^4.31.1",
"@typescript-eslint/parser": "^4.31.1",
"@zazuko/rdf-vocabularies": "^2021",
"babel-plugin-add-import-extension": "^1.4.3",
"core-js": "^2.5.0",
"@types/sinon-chai": "^3.2.9",
"@typescript-eslint/eslint-plugin": "^5.60.1",
"@typescript-eslint/parser": "^5.60.1",
"@zazuko/prefixes": "^2.0.0",
"chai": "^4.3.7",
"chai-as-promised": "^7.1.1",
"docsify-cli": "^4.4.3",
"eslint": "^7.32.0",
"eslint-config-standard": "^16.0.3",
"eslint": ">=6",
"eslint-config-standard": ">=11",
"eslint-import-resolver-typescript": "^2.5.0",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-import": ">=2",
"eslint-plugin-jest": "^24.1.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-n": ">=15",
"eslint-plugin-node": ">=11",
"eslint-plugin-promise": ">=6",
"eslint-plugin-require-extensions": ">=0.1.3",
"eslint-plugin-standard": "^4.0.1",
"husky": "^1.0.0",
"istanbul-instrumenter-loader": "^3.0.1",
"jest": "^26.6.0",
"husky": "^8.0.3",
"isomorphic-form-data": "^2.0.0",
"json-server": "^0.16.3",
"jsonld": "^1.4.0",
"jsonld": "^8.2.0",
"lint-staged": "^11.0.0",
"node-fetch": "^2.6.0",
"mocha": "^10.2.0",
"mocha-chai-jest-snapshot": "^1.1.4",
"node-fetch": "^3.3.1",
"npm-run-all": "^4.1.5",
"rdf-ext": "^1.3.5",
"sinon": "^13",
"standard": "^16.0.3",
"rdf-ext": "^2.2.0",
"sinon": "^15.2.0",
"sinon-chai": "^3.7.0",
"standard": ">=11",
"string-to-stream": "^3.0.1",
"ts-node": "^8.8.2",
"typescript": "^4.0.2",
"ts-node": "^10.9.1",
"typescript": "~4.2",
"whatwg-fetch": "^3.0.0"
},
"lint-staged": {
"*.{js,ts}": [
"eslint --quiet --fix --ignore-path .eslintignore"
]
},
"mocha": {
"extension": "ts",
"loader": "ts-node/esm",
"require": [
"test/mocha-setup.cjs"
]
},
"publishConfig": {
"access": "public"
}
Expand Down
14 changes: 7 additions & 7 deletions src/Constants.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { hydra } from '@tpluscode/rdf-ns-builders'

export const ContentTypes = {
problemDetails: 'application/problem+json',
problemDetails: 'application/problem+json',
}

export const Headers = {
Link: 'Link',
Location: 'Location',
ContentType: 'Content-Type',
Link: 'Link',
Location: 'Location',
ContentType: 'Content-Type',
}

export const LinkRelations = {
canonical: 'canonical',
context: 'http://www.w3.org/ns/json-ld#context',
apiDocumentation: hydra.apiDocumentation.value,
canonical: 'canonical',
context: 'http://www.w3.org/ns/json-ld#context',
apiDocumentation: hydra.apiDocumentation.value,
}
Loading

0 comments on commit f48a8a4

Please sign in to comment.