Skip to content

Difficult to use from Webpack #27

@lapo-luchini

Description

@lapo-luchini

Due to the way that environments are detected it is difficult to use from Webpack, as both Node is detected (thus requiring fs and ws) and window is detected (thus not exporting to module.exports). Those issues can be worked around using imports-loader and exports-loader, but it would probably be nice to have a way to detect Webpack and "just work" OOTB.

I was capable of using [email protected] using the following configuration:

module.exports = {
    mode: 'production',
    
    node: {
        // required by xmllint (but not really used in the browser)
        fs: 'empty',
    },
    externals: {
        // required by xmllint (but not really used in the browser)
        ws: '{}',
    },
    module: {
        rules: [{
            test: path.resolve(__dirname, 'node_modules/xmllint/xmllint.js'),
            use: [
                'imports-loader?require=>null',
                'exports-loader?xmllint'
            ]
        }],
    },
};
```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions