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

Can't import oas from npm #35

Open
JasonWoof opened this issue May 12, 2020 · 5 comments
Open

Can't import oas from npm #35

JasonWoof opened this issue May 12, 2020 · 5 comments

Comments

@JasonWoof
Copy link

import {oas as koaOas3} from 'koa-oas3';
        ^^^
SyntaxError: The requested module 'koa-oas3' does not provide an export named 'oas'

Sorry if this is just a typo or something, I'm tired.

I have this in my package.json: "koa-oas3": "latest", and package-lock.json says it's got version "0.18.0".

@supertong
Copy link
Collaborator

Hey, @JasonWoof, I won't able to reproduce the issue. Do you have a repo that makes the issue reproducible?

@JasonWoof
Copy link
Author

#!/bin/bash
echo "import {oas as koaOas3} from 'koa-oas3'; console.log('It worked!');" | docker run -i --rm -v "$(readlink -f "$(dirname "$0")")":/var/pwd -w /var/pwd node:latest bash -c 'npm install -y koa koa-oas3 </dev/null || exit $?; node --input-type=module -'

@supertong
Copy link
Collaborator

Hey @JasonWoof , that's because the package is only compiled to commonJs modules at the moment. Sorry for the confusion.

@mahnunchik
Copy link

Any news?

@JasonWoof
Copy link
Author

@mahnunchik Here's what I've learned since making this bug report: From es6 modules, you can import common-js modules, you just can't import their inner symbols directly, ie you can do something like this:

import koaOas3 from 'koa-oas3'; // import the whole module
const oas = koaOas3.oas; // extract the part you want

(I didn't test the above, sorry if I made a typo or got any of the names wrong)

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

No branches or pull requests

3 participants