mysticatea / eslint4b

ESLint which works in browsers.
MIT License
37 stars 19 forks source link

Problem trying to use with webpack #11

Open knolleary opened 3 years ago

knolleary commented 3 years ago

Hi,

I'm trying to use webpack to create a bundle that includes eslint4b to run in a WebWorker.

I have the following webpack.config.js:

{
    entry: path.resolve(__dirname, 'lib/rules/function-eslint/index.js'),
    output: {
        filename: 'nrlint-plugin-rules-function-eslint.js',
        path: path.resolve(__dirname, 'resources'),
        library: {
            name: ['nrlint','rules'],
            type: 'assign-properties'
        }
    },
    resolve: {
        fallback: {
            "assert": path.resolve(__dirname, 'lib/rules/function-eslint/empty.js'),
            "util":   false,
            "path":   false
        }
    },
    mode: 'production',
    target: ['webworker']
}

When I run webpack, I get multiple errors of the sort:

Module not found: Error: Can't resolve '@eslint/eslintrc/conf/environments' in '/Users/nol/code/node-red/nrlint/node_modules/eslint4b/dist'

This happens for:

I have found I need to have the full eslint installed as a dependency of my own module for the webpack to work. Is that expected?

k-toumura commented 3 years ago

Since ESLint v7.8.0, some features have been extracted to @eslint/eslintrc, so I think we need to register it in dependencies in package.json.

In scripts/build.js, package id extraction logic does not deal with scoped modules (modules starting with @). This may be why @eslint/eslintrc is not automatically registered in the dependencies.

yfwz100 commented 3 years ago

Maybe a PR is needed?