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

Add ability to create more life-like node module packages #4

Open
itsdouges opened this issue Jan 27, 2020 · 2 comments
Open

Add ability to create more life-like node module packages #4

itsdouges opened this issue Jan 27, 2020 · 2 comments

Comments

@itsdouges
Copy link

itsdouges commented Jan 27, 2020

Atm when using addMock it adds a typescript package. Can we add the ability to add js ones as well?

I can kind of work around this by doing:

.addSource({ path: 'node_modules/mixins/index.js', contents: `export const blue = 'blue';` })
.addSource({ path: 'node_modules/mixins/index.d.ts', contents: `export const blue: string;` });

though

interestingly if i don't define a type def i can get the real ast (using allowJs: true). if it IS defined i get the type def instead which is shit. wonder how i can get the real one!

@marionebl
Copy link
Owner

Atm when using addMock it adds a typescript package. Can we add the ability to add js ones as well?

Sure. I thought about adding an API to add a full module from disk. Would that fit this use case?

interestingly if i don't define a type def i can get the real ast (using allowJs: true). if it IS defined i get the type def instead which is shit. wonder how i can get the real one!

Have checked if this differs from the behavior you get from packages that publish inline type definitions? My hunch is it would be the same...

@itsdouges
Copy link
Author

Sure. I thought about adding an API to add a full module from disk. Would that fit this use case?

i guess so :)


i think you're right it would be the same. i'll be investigating through the week - at least knowing that tsc can parse js and give me the AST is promising, but getting it to give me it over the type defs is.. another story.

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

2 participants