herberttn / bytenode-webpack-plugin

Compile JavaScript into bytecode using bytenode
MIT License
105 stars 27 forks source link

refactor(examples): latest electron-forge and typescript configs #19

Closed jjeff closed 1 year ago

jjeff commented 1 year ago

This PR updates the modules in examples/electron-forge-typescript-webpack. This means moving from beta Electron Forge to release 6, which changes the configuration files some. I also updated all of the config files to Typescript, and included the webpack.preload.config file in the configuration.

This all works fine on the Mac.

HOWEVER, on Windows, there's currently a bug in either Electron Forge, Bytenode Webpack Plugin, or Bytenode which generates the following error when launching:

image

The full error is

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:360:18)
    at wrapSafe (node:internal/modules/cjs/loader:1062:15)
    at Module._compile (node:internal/modules/cjs/loader:1097:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1196:10)
    at Module.load (node:internal/modules/cjs/loader:1011:32)
    at Module._load (node:internal/modules/cjs/loader:846:12)
    at f._load (node:electron/js2c/asar_bundle:2:13328)
    at Module.require (node:internal/modules/cjs/loader:1035:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at ./index.ts (C:\Users\jeff\OneDrive\Documents\Code\bytenode-webpack-plugin\examples\electron-forge-typescript-webpack\.webpack\main\main.js:368:18)
jjeff commented 1 year ago

Further examination: The line linked in the error (line 368 of main.js) contains the following:

"use strict";
module.exports = require("C:\\Users\\jeff\\OneDrive\\Documents\\Code\\bytenode-webpack-plugin\\examples\\electron-forge-typescript-webpack\\src\\index.ts");

It looks like the original typescript file is being required here rather than the .jsc file.

jjeff commented 1 year ago

..and on Mac, this same line reads:

"use strict";
module.exports = require("./main.compiled.jsc");
herberttn commented 1 year ago

Hoping to look into it this weekend

github-actions[bot] commented 1 year ago

:tada: This PR is included in version 2.3.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: