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

Update: Add /universal entrypoint (fixes #50) #51

Merged
merged 3 commits into from Aug 7, 2021
Merged

Update: Add /universal entrypoint (fixes #50) #51

merged 3 commits into from Aug 7, 2021

Conversation

nzakas
Copy link
Member

@nzakas nzakas commented Aug 6, 2021

Adds a new /universal entrypoint that exports only members that are browser-safe. Once this is merged, we should change this line in linter.js from:

    const {
        Legacy: {
            ConfigOps,
            ConfigValidator,
            environments: BuiltInEnvironments
        }
    } = require("@eslint/eslintrc"),

to

const    {
        Legacy: {
            ConfigOps,
            ConfigValidator,
            environments: BuiltInEnvironments
        }
    } = require("@eslint/eslintrc/universal"),

@nzakas nzakas added the enhancement New feature or request label Aug 6, 2021
@mdjermanovic
Copy link
Member

Updated eslint/eslint#14865 to use this branch, but the Browser Test still doesn't work.

ERROR in ./node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs 8:15-32
Module not found: Error: Can't resolve 'module' in '/home/runner/work/eslint/eslint/node_modules/@eslint/eslintrc/dist'
 @ ./lib/linter/linter.js 23:4-41

webpack compiled with 1 error

I believe this is the cause:

import { createRequire } from "module";
const require = createRequire(import.meta.url);
const metaSchema = require("ajv/lib/refs/json-schema-draft-04.json");

(ajv.js is imported from config-validator.js).

We might need to copy the content of ajv/lib/refs/json-schema-draft-04.json into our own ESM module, and import that module here instead of loading JSON file.

},
"files": [
"lib",
"conf",
"LICENSE",
"dist/eslintrc.cjs"
"dist"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"dist"
"dist/eslintrc.cjs",
"dist/eslintrc-universal.cjs"

if we don't want to publish .map files

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of a reason not to publish map files.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know, we are not publishing map files in other dual packages e.g., eslint/eslint-visitor-keys#24 (comment)

@nzakas
Copy link
Member Author

nzakas commented Aug 6, 2021

Oops, good call. Updated.

Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, all checks have passed on eslint/eslint#14865.

@mdjermanovic mdjermanovic linked an issue Aug 6, 2021 that may be closed by this pull request
@nzakas nzakas merged commit aaf282e into main Aug 7, 2021
@nzakas nzakas deleted the universal branch August 7, 2021 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ESLint Browser Test fails
2 participants