realm / realm-js

Realm is a mobile database: an alternative to SQLite & key-value stores
https://realm.io
Apache License 2.0
5.74k stars 566 forks source link

Improve regex for webpack.externals in Electron Example app #6271

Open bimusiek opened 9 months ago

bimusiek commented 9 months ago

Problem

Current regex requires user to put needed packages in allow-list all the time.

Solution

Wouldn't it better to do


const path = require("node:path");
const nodeExternals = require("webpack-node-externals");

module.exports = {
    webpack: {
        configure: {
            target: "electron-renderer",
            externals: [
                nodeExternals({
                    allowlist: [/^(?!.*(^realm)$)/i],
                    additionalModuleDirs: [path.resolve(__dirname, '../../../node_modules')],
                }),
            ],
        },
    },
};

so we basically say, pack everything except realm.

Alternatives

No response

How important is this improvement for you?

Fairly niche but nice to have anyway

Feature would mainly be used with

Atlas Device Sync

kneth commented 9 months ago

@bimusiek Thank you for the suggestion. @takameyer what do you think?