Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constructor is Default Export, Not a Named Export #4

Open
dhurlburtusa opened this issue Apr 13, 2019 · 2 comments
Open

Constructor is Default Export, Not a Named Export #4

dhurlburtusa opened this issue Apr 13, 2019 · 2 comments

Comments

@dhurlburtusa
Copy link

Version: 1.2.1
Syntax: CommonJS

Using the following:

const { FilterWarningsPlugin } = require('webpack-filter-warnings-plugin');

...
  plugins: [
    new FilterWarningsPlugin(...),
  ],
...

I get a "TypeError: FilterWarningsPlugin is not a constructor" error message.

Changing "import" to:

const FilterWarningsPlugin = require('webpack-filter-warnings-plugin');

fixes the issue.

So, either the documentation (i.e., the README.md) is incorrect, or the package was built incorrectly.

In the dist directory of webpack-filter-warnings-plugin in my node_modules, I have the following files:

// cjs.js
'use strict';

module.exports = require('./index').default;

and

// index.js
'use strict';

...

exports.default = FilterWarningsPlugin;

The main property in package.json has "dist/cjs.js".

I am going to assume the README.md is incorrect, and I am going to create a PR to update it.

@dhurlburtusa
Copy link
Author

Oh, I see what is going on. The documentation is for the new, unreleased changes for the change to TypeScript. But the latest release is prior to the TypeScript changes.

A way to mitigate this issue of the documentation being out of sync with the latest released code is to follow something like GitFlow where the documentation and code on the master branch represent the latest release. Then the develop branch can have the updated documentation and code.

Be sure to leave the repo's default branch as master so that it is what is seen by default.

@cdeutsch
Copy link

Oh man. Just went through this same thing. 🤦‍♂

Thanks for filing this issue 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants