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

Issue importing oas ruleset from @stoplight/spectral-rulesets #2240

Closed
kingcanova opened this issue Aug 12, 2022 · 6 comments · Fixed by #2243
Closed

Issue importing oas ruleset from @stoplight/spectral-rulesets #2240

kingcanova opened this issue Aug 12, 2022 · 6 comments · Fixed by #2243
Assignees
Labels
released t/bug Something isn't working

Comments

@kingcanova
Copy link

Describe the bug
When trying to use the oas ruleset exported by the @stoplight/spectral-rulesets package in a backstage.io custom plugin an error occurs that does not let me render my frontend page or use the ruleset.

The error that is displayed on the webpage is:
ERROR 501: Lazy loaded chunk failed to load, try to reload the page: __importDefault is not defined

Here is how the packages are being imported:

import { Spectral, Document } from "@stoplight/spectral-core";
import { oas } from "@stoplight/spectral-rulesets";

Ive also tried importing it using "require" but get the same error when trying that way.

Here is how the packages are being used:

const spectral = new Spectral();
console.log(oas);
const myRuleset = {
    extends: [oas],
    rules: {
        "no-empty-description": {
            given: "$..description",
            message: "Description must not be empty",
            then: {
                function: truthy,
            },
        },
    },
}
useEffect(() => {
    spectral.setRuleset(myRuleset);
    console.log(spectral.ruleset);
    spectral.run(myDocument).then(setLintIssues);
}, []);

Environment:
Node: v1.15.1
Typescript: 4.6.4
Spectral-core: 1.13.0
Spectral-functions: 1.7.0
Spectral-parsers: 1.0.1
Spectral-ruleset-bundler: 1.3.1
Spectral-rulesets: 1.11.1
OS: MacOS Monterey
Browser: Chrome 103

@P0lip
Copy link
Contributor

P0lip commented Aug 12, 2022

That is weird. We fixed __importDefault issue some time ago. 🤔
Could you share the error stack for me to see the actual source of that error?

@kingcanova
Copy link
Author

Hi @P0lip, I dont seem to have any other error logs than the one posted above (or im not sure where they would be) that shows up where the component that is utilizing the spectral should be rendered. I can fully render my component and run the above code on an example document if I dont import oas and dont add it as an extension to the custom ruleset.

@kingcanova
Copy link
Author

Here is a screenshot:
image

@P0lip
Copy link
Contributor

P0lip commented Aug 15, 2022

if I dont import oas and dont add it as an extension to the custom ruleset.

got it. Would it be possible for you to send some sample project so I can take a look at the code that gets executed?

@P0lip
Copy link
Contributor

P0lip commented Aug 15, 2022

@P0lip P0lip self-assigned this Aug 15, 2022
@P0lip P0lip added the t/bug Something isn't working label Aug 15, 2022
@stoplight-bot
Copy link
Collaborator

🎉 This issue has been resolved in version @stoplight/spectral-rulesets-v1.11.2 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants