Skip to content

Commit

Permalink
Fix electron webpack samples (#6864)
Browse files Browse the repository at this point in the history
The electron webpack samples' transforms weren't updated when we changed
to .cjs extensions which breaks native module imports (node extensions).
This PR addresses by adding .cjs to the list of files to transform
  • Loading branch information
tnorling authored Feb 1, 2024
1 parent 4d4516a commit e7a5551
Show file tree
Hide file tree
Showing 5 changed files with 66,246 additions and 74,750 deletions.
8 changes: 4 additions & 4 deletions extensions/samples/electron-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"make": "electron-forge make",
"publish": "electron-forge publish",
"lint": "eslint --ext .ts,.tsx .",
"build:package": "cd ../../lib/msal-common && npm run build && cd ../msal-node && npm run build",
"build:package": "npm run build --workspace=@azure/msal-common --workspace=@azure/msal-node --workspace=@azure/msal-node-extensions",
"start:build": "npm run build:package && npm start"
},
"keywords": [
Expand Down Expand Up @@ -53,9 +53,9 @@
"typescript": "~4.5.4"
},
"dependencies": {
"@azure/msal-node": "^2.0.0-beta.0",
"@azure/msal-node-extensions": "^1.0.0-beta.0",
"@azure/msal-node": "^2.6.2",
"@azure/msal-node-extensions": "^1.0.10",
"bootstrap": "^4.6.2",
"electron-squirrel-startup": "^1.0.0"
}
}
}
54 changes: 27 additions & 27 deletions extensions/samples/electron-webpack/webpack.rules.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import type { ModuleOptions } from 'webpack';
import type { ModuleOptions } from "webpack";

export const rules: Required<ModuleOptions>['rules'] = [
// Add support for native node modules
{
// We're specifying native_modules in the test because the asset relocator loader generates a
// "fake" .node file which is really a cjs file.
test: /native_modules\/.+\.node$/,
use: 'node-loader',
},
{
test: /\.(m?js|node)$/,
parser: { amd: false },
use: {
loader: '@vercel/webpack-asset-relocator-loader',
options: {
outputAssetBase: 'native_modules',
},
export const rules: Required<ModuleOptions>["rules"] = [
// Add support for native node modules
{
// We're specifying native_modules in the test because the asset relocator loader generates a
// "fake" .node file which is really a cjs file.
test: /native_modules\/.+\.node$/,
use: "node-loader",
},
},
{
test: /\.tsx?$/,
exclude: /(node_modules|\.webpack)/,
use: {
loader: 'ts-loader',
options: {
transpileOnly: true,
},
{
test: /\.([m|c]?js|node)$/,
parser: { amd: false },
use: {
loader: "@vercel/webpack-asset-relocator-loader",
options: {
outputAssetBase: "native_modules",
},
},
},
{
test: /\.tsx?$/,
exclude: /(node_modules|\.webpack)/,
use: {
loader: "ts-loader",
options: {
transpileOnly: true,
},
},
},
},
];
Loading

0 comments on commit e7a5551

Please sign in to comment.