Closed Randgalt closed 4 years ago
I've worked around much of this.
Ah - SO close. I'm down to 1 error and a few warnings. Here's the error:
ERROR in /Users/jordanzimmerman/dev/oss/journalator-electron/journalator/node_modules/live-plugin-manager/src/PluginVm.ts
./node_modules/live-plugin-manager/src/PluginVm.ts
[tsl] ERROR in /Users/jordanzimmerman/dev/oss/journalator-electron/journalator/node_modules/live-plugin-manager/src/PluginVm.ts(189,9)
TS2740: Type '((requiredName: string) => any) & { resolve: RequireResolve; cache: {}; extensions: RequireExtensions; main: Module | undefined; }' is missing the following properties from type 'NodeRequire': requireActual, requireMock, ensure, context, and 2 more.
This is using ts-loader
, "target": "ESNext"
, "module": "commonjs"
and a few other things (I can show you any file you want).
Huzzah! I got it working with ts-loader. I had to set transpileOnly: true
. I think there's a real bug here. In https://github.com/davideicardi/live-plugin-manager/blob/master/src/PluginVm.ts#L189 you are missing some properties per my comment above (https://github.com/davideicardi/live-plugin-manager/issues/23#issuecomment-629566274)
I will check better, bu I think that depends on the node typings version. I use version 13 in latest release. What version do you have? Can you show your dependencies?
"devDependencies": {
"@babel/core": "^7.9.6",
"@babel/plugin-proposal-class-properties": "^7.4.4",
"@babel/polyfill": "^7.4.4",
"@babel/preset-env": "^7.9.6",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.3.3",
"@hot-loader/react-dom": "^16.8.6",
"@types/electron-devtools-installer": "^2.2.0",
"@types/jest": "^24.0.13",
"@types/node": "^13.13.2",
"@types/react": "^16.8.18",
"@types/react-dom": "^16.8.4",
"@types/react-redux": "^7.0.9",
"@types/react-test-renderer": "^16.8.1",
"@types/webdriverio": "^4.8.7",
"@types/webpack-env": "^1.13.3",
"@typescript-eslint/eslint-plugin": "^2.4.0",
"@typescript-eslint/parser": "^2.4.0",
"babel-loader": "^8.1.0",
"cross-env": "^5.1.3",
"css-loader": "^2.1.1",
"electron": "^3.1.9",
"electron-builder": "^22.3.2",
"electron-devtools-installer": "^2.2.4",
"eslint": "^6.5.1",
"eslint-config-airbnb": "^18.0.1",
"eslint-config-prettier": "^6.4.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-react": "^7.16.0",
"eslint-plugin-react-hooks": "^1.7.0",
"file-loader": "^3.0.1",
"fork-ts-checker-webpack-plugin": "^1.3.4",
"html-webpack-plugin": "^3.2.0",
"husky": "^4.2.1",
"image-webpack-loader": "^4.6.0",
"jest": "^24.8.0",
"lint-staged": "^10.0.7",
"node-sass": "^4.12.0",
"prettier": "^1.18.2",
"react-hot-loader": "^4.8.8",
"react-test-renderer": "^16.8.6",
"redux-devtools-extension": "^2.13.5",
"sass-loader": "^7.1.0",
"source-map-loader": "^0.2.4",
"spectron": "^5.0.0",
"style-loader": "^0.23.1",
"ts-jest": "^24.0.2",
"ts-loader": "^7.0.4",
"typescript": "^3.8.3",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.2",
"webpack-dev-server": "^3.4.1",
"webpack-merge": "^4.2.1"
},
"dependencies": {
"@material-ui/core": "^4.9.14",
"@material-ui/icons": "^4.9.1",
"fs-extra": "^9.0.0",
"live-plugin-manager": "^0.14.1",
"node-polyglot": "^2.4.0",
"react": "^16.8.6",
"react-dom": "^16.8.6"
}
The following configurations works fine:
{
"name": "test-lpm",
"version": "1.0.0",
"description": "",
"main": "index.js",
"devDependencies": {
"@types/node": "^13.13.2",
"typescript": "^3.8.3"
},
"dependencies": {
"live-plugin-manager": "^0.14.1"
},
"scripts": {
"build": "tsc"
},
"author": "",
"license": "ISC"
}
{
"compilerOptions": {
"target": "ESNext",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
}
}
import {PluginManager} from "live-plugin-manager";
const p = new PluginManager();
p.install('moment')
I have tried with your dependencies and I have the same errors. I suspect that there is some incompatible library. I will try to investigate further...
FYI - I used a builder to get to the electron app. I'll likely abandon this build and start from scratch.
I have found the incompatible libraries, they are @types/jest
and @types/webpack-env
.
If you remove these two libraries it works fine. I think that the problem is that they "override" the require
function adding additional properties.
Not sure how can I solve this on my side, I will think about it... in the meantime maybe you can remove it? Do you need types for these libraries?
Do you need types for these libraries?
Probably not. tbh I'm very new to the Javascript world and am just learning everything. Your plugin manager is fantastic and just what I was looking for but finding the right framework for integrating it has been an issue for me. Frankly the loaders and dev environment are not what I want. I will switch to express and managing things myself along with your plugin manager. That will remove any of these incompatibilities - I'll just get webpack, ts-loader and babel out of the way and rely on pure Javascript for plugins. I can still write my own code in Typescript with tsc.
I'm at
esnext
,"typescript": "^3.9.2"
,"ts-loader": "^7.0.4"
- let me know if you need anything else.