Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve loading of submodules #1939

Closed
wants to merge 8 commits into from
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
node:
- 18
- 20
- 21
os:
- ubuntu-latest
- windows-latest
- macos-latest

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node }}
Expand Down
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## [Unreleased][unreleased]

## [3.0.13][] - 2023-10-22

- Fix serve static not in cache (e.g. certbot challenge)
- Fix `application.invoke` availability on `start` hook
- Support node.js 21.x

## [3.0.12][] - 2023-10-22

- Update metacom and metautil with important error.code and timeout fixes
Expand Down Expand Up @@ -352,7 +358,8 @@ First generation of application server with following features
- Connection drivers for database engines: MongoDB, PgSQL, Oracle, MySQL
- Support GeoIP, health monitoring, task scheduling, server-side templating

[unreleased]: https://github.com/metarhia/impress/compare/v3.0.12...HEAD
[unreleased]: https://github.com/metarhia/impress/compare/v3.0.13...HEAD
[3.0.13]: https://github.com/metarhia/impress/compare/v3.0.12...v3.0.13
[3.0.12]: https://github.com/metarhia/impress/compare/v3.0.11...v3.0.12
[3.0.11]: https://github.com/metarhia/impress/compare/v3.0.10...v3.0.11
[3.0.10]: https://github.com/metarhia/impress/compare/v3.0.9...v3.0.10
Expand Down
14 changes: 12 additions & 2 deletions lib/deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,18 @@ const loadModule = (name) => {
const subKeys = Object.keys(pkg.exports).map((key) => key.substring(2));
const subNames = subKeys.filter(validSubmodules);
for (const subName of subNames) {
const sub = appRequire(name + '/' + subName);
lib[subName] = sub;
try {
const sub = appRequire(name + '/' + subName);
if (lib[subName] && lib[subName] === sub[subName]) continue;
lib[subName] = sub;
} catch (e) {
if (e.message.startsWith("Cannot find module '")) {
const moduleName = e.message.substring(20, e.message.indexOf("'\n"));
const optional = pkg.peerDependenciesMeta?.[moduleName]?.optional;
if (optional) continue;
else throw e;
}
}
}
return lib;
};
Expand Down
71 changes: 31 additions & 40 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "impress",
"version": "3.0.12",
"version": "3.0.13",
"author": "Timur Shemsedinov <[email protected]>",
"description": "Enterprise application server for Node.js",
"license": "MIT",
Expand Down Expand Up @@ -38,7 +38,7 @@
"readmeFilename": "README.md",
"repository": {
"type": "git",
"url": "https://github.com/metarhia/impress"
"url": "git+https://github.com/metarhia/impress.git"
},
"bugs": {
"url": "https://github.com/metarhia/impress/issues",
Expand All @@ -51,23 +51,27 @@
},
"main": "impress.js",
"types": "types/impress.d.ts",
"files": ["lib/", "schemas/", "types/"],
"files": [
"lib/",
"schemas/",
"types/"
],
"scripts": {
"test": "npm run lint && npm run types && metatests test/",
"types": "tsc -p types/tsconfig.json",
"lint": "eslint . && prettier -c \"**/*.js\" \"**/*.json\" \"**/*.md\" \"**/*.ts\"",
"fmt": "prettier --write \"**/*.js\" \"**/*.json\" \"**/*.md\" \"**/*.ts\""
},
"engines": {
"node": "18 || 20"
"node": "^18.15 || 20 || 21"
},
"dependencies": {
"metacom": "^3.1.2",
"metaconfiguration": "^2.1.11",
"metalog": "^3.1.13",
"metaschema": "^2.1.5",
"metautil": "^3.15.0",
"metavm": "^1.3.0",
"metavm": "^1.4.0",
"metawatch": "^1.1.1"
},
"devDependencies": {
Expand Down
Loading