Skip to content

Commit

Permalink
fix: Unhandled rejection TypeError: A value [object Object] was yield…
Browse files Browse the repository at this point in the history
…ed that could not be treated as a promise
  • Loading branch information
develar committed Jun 20, 2019
1 parent 3254823 commit f0b8dfb
Show file tree
Hide file tree
Showing 7 changed files with 282 additions and 149 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ node_modules/
lerna-debug.log
packages/electron-webpack/readme.md
_book/
packages/electron-webpack/scheme.json
#packages/electron-webpack/scheme.json

# to not exclude .js.snap (jest snapshots)
/test/out/**/*.js
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"author": "Vladimir Krivosheev <develar@gmail.com>",
"scripts": {
"compile": "cross-env ts-babel packages/electron-webpack test && yarn schema",
"compile": "cross-env ts-babel packages/electron-webpack test",
"lint": "tslint -c ./node_modules/electron-builder-tslint-config/tslint.json -p packages/electron-webpack --exclude '**/*.js'",
"release": "BABEL_ENV=production yarn compile && ./npm-publish.sh && conventional-changelog -p angular -i CHANGELOG.md -s",
"test": "yarn compile && yarn lint && jest",
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-webpack/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "electron-webpack",
"version": "2.7.0",
"version": "2.7.1",
"license": "MIT",
"author": "Vladimir Krivosheev <develar@gmail.com>",
"main": "out/main.js",
Expand Down
174 changes: 174 additions & 0 deletions packages/electron-webpack/scheme.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"definitions": {
"ElectronWebpackConfigurationMain": {
"additionalProperties": false,
"properties": {
"extraEntries": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"additionalProperties": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "string"
}
]
},
"type": "object"
},
{
"type": "string"
}
],
"description": "The extra [entry points](https://webpack.js.org/concepts/entry-points/)."
},
"sourceDirectory": {
"type": [
"null",
"string"
]
},
"webpackConfig": {
"type": [
"null",
"string"
]
}
},
"title": "ElectronWebpackConfigurationMain",
"type": "object"
},
"ElectronWebpackConfigurationRenderer": {
"additionalProperties": false,
"properties": {
"dll": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"additionalProperties": {
},
"type": "object"
},
{
"type": "null"
}
]
},
"sourceDirectory": {
"type": [
"null",
"string"
]
},
"template": {
"type": [
"null",
"string"
]
},
"webpackConfig": {
"type": [
"null",
"string"
]
},
"webpackDllConfig": {
"type": [
"null",
"string"
]
}
},
"title": "ElectronWebpackConfigurationRenderer",
"type": "object"
}
},
"properties": {
"commonDistDirectory": {
"type": [
"null",
"string"
]
},
"commonSourceDirectory": {
"type": [
"null",
"string"
]
},
"electronVersion": {
"type": "string"
},
"externals": {
"items": {
"type": "string"
},
"type": "array"
},
"main": {
"anyOf": [
{
"$ref": "#/definitions/ElectronWebpackConfigurationMain"
},
{
"type": "null"
}
]
},
"projectDir": {
"type": [
"null",
"string"
]
},
"renderer": {
"anyOf": [
{
"$ref": "#/definitions/ElectronWebpackConfigurationRenderer"
},
{
"type": "null"
}
]
},
"staticSourceDirectory": {
"type": [
"null",
"string"
]
},
"title": {
"type": [
"null",
"string",
"boolean"
]
},
"whiteListedModules": {
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
}

17 changes: 9 additions & 8 deletions packages/electron-webpack/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ export class WebpackConfigurator {
}
}

this._configuration = await this.applyCustomModifications(this.config)
// noinspection ES6RedundantAwait
this._configuration = await Promise.resolve(this.applyCustomModifications(this.config))

return this.config
}
Expand All @@ -254,24 +255,24 @@ export class WebpackConfigurator {
const customModule = require(path.join(this.projectDir, configPath))
if (typeof customModule === "function") {
return customModule(config)
} else {
}
else {
return merge.smart(config, customModule)
}
}

if (this.type === "renderer" && renderer && renderer.webpackConfig) {
return applyCustom(renderer.webpackConfig)
}

if (this.type === "renderer-dll" && renderer && renderer.webpackDllConfig) {
else if (this.type === "renderer-dll" && renderer && renderer.webpackDllConfig) {
return applyCustom(renderer.webpackDllConfig)
}

if (this.type === "main" && main && main.webpackConfig) {
else if (this.type === "main" && main && main.webpackConfig) {
return applyCustom(main.webpackConfig)
}

return config
else {
return config
}
}

private computeExternals() {
Expand Down
Loading

0 comments on commit f0b8dfb

Please sign in to comment.