Skip to content

Unable to use library in typescript project complied with rollup #23

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

Closed
veleek opened this issue Jan 31, 2021 · 4 comments
Closed

Unable to use library in typescript project complied with rollup #23

veleek opened this issue Jan 31, 2021 · 4 comments

Comments

@veleek
Copy link

veleek commented Jan 31, 2021

I'm importing the package into a typescript project that's compiled with rollup. Unfortunately, when I try to build with this referenced (import { AStarFinder } from "astar-typescript";) rollup fails with the error:

Error: 'AStarFinder' is not exported by node_modules\astar-typescript\dist\astar.js, imported by game.ts

I've fiddled around with various plugin changes and options for plugin-commonjs (stuff like adding it to the includes list to force it to be parsed as a CommonJS module but nothing seems to work. Can someone help me figure out the incantation to get this working with rollup?

This is more of a rollup question I suppose, but if you have any thoughts or ideas around ways to get it working that would be great!

@digitsensitive
Copy link
Owner

Please be sure, that your configuration files are correct.
Have a look at the example folders.

@veleek
Copy link
Author

veleek commented Feb 2, 2021

Yeah, everything appears to be correct. I think it's probably more of a specific rollup issue, was just hoping maybe you had some insight into how it should work.

@veleek veleek closed this as completed Feb 2, 2021
@veleek
Copy link
Author

veleek commented Feb 2, 2021

In case anybody else running into this problem, I'm hoping it'll be answered by this Stack Overflow thread.

@agaAdams
Copy link

agaAdams commented Jul 16, 2021

You have to tell the 'rollup-commonjs-plugin' to convert your imported library's modules into a format Rollup can use:

In your rollup config edit the part concerning the commonjs-plugin:

commonjs({
    include: [
        'node_modules/eventemitter3/**',
        'node_modules/phaser/**',
        'node_modules/astar-typescript/**',
        'node_modules/lodash/**',
    ],
    exclude: [ 
        'node_modules/phaser/src/polyfills/requestAnimationFrame.js',
    ],
    sourceMap: true,
}),

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