Skip to content

hdf5.File is not a constructor when bundled with webpack #115

Description

@ziyuang

I've created a small example: https://gist.github.com/ziyuang/30f135a2405bbeeb004fe4c8a05e8f5c.
Here are the files

// index.js
import { hdf5 } from 'hdf5';
import { Access } from 'hdf5/lib/globals';

let f = new hdf5.File('test.hdf5', Access.ACC_RDONLY);
// package.json
{
  "name": "hdf5_test",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "hdf5": "https://github.com/HDF-NI/hdf5.node#v12"
  },
  "devDependencies": {
    "file-loader": "^6.0.0",
    "webpack": "^4.44.1",
    "webpack-cli": "^3.3.12"
  }
}
// webpack.config.js
const path = require('path');

module.exports = {
    entry: './index.js',
    target: 'node',
    module: {
        rules: [
            {
                test: /\.node$/,
                use: 'file-loader'
            },
        ],
    },
    mode: 'development',
    output: {
        filename: 'index.js',
        path: path.resolve(__dirname, 'dist')
    },
};

Then after npx webpack && cd dist && node index.js, I got the error

let f = new hdf5__WEBPACK_IMPORTED_MODULE_0__["hdf5"].File('test.hdf5', hdf5_lib_globals__WEBPACK_IMPORTED_MODULE_1__["Access"].ACC_RDONLY);
        ^

TypeError: hdf5__WEBPACK_IMPORTED_MODULE_0__.hdf5.File is not a constructor

What am I missing? Thanks.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions