Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Usage in a TypeScript project #2

Closed
vogloblinsky opened this issue Feb 13, 2017 · 8 comments
Closed

Usage in a TypeScript project #2

vogloblinsky opened this issue Feb 13, 2017 · 8 comments

Comments

@vogloblinsky
Copy link

I am in an Angular project coded in TypeScript.

import { Spritz } from 'spritz.js';

Simple loading spritz.js using ES6 syntax, and i got this error :

WARNING in ./src/app/views/game/game.component.ts
16:25-31 "export 'Spritz' was not found in 'spritz.js'
@vogloblinsky
Copy link
Author

Fixed using this syntax, not very nice...

const SpritzModule = require('spritz.js'),
      Spritz = SpritzModule.default;

@maoosi
Copy link
Owner

maoosi commented Feb 13, 2017

What about import Spritz from 'spritz.js'; instead of import { Spritz } from 'spritz.js'; ?

@vogloblinsky
Copy link
Author

import Spritz from 'spritz.js';

breaks too

ERROR in /Volumes/Data/wamp/SII/RetD/coding-game/coding-game-frontend/src/app/views/game/game.component.ts (3,20): Cannot find module 'spritz.js'.)
webpack: Failed to compile.

@maoosi
Copy link
Owner

maoosi commented Feb 13, 2017

One last thing that you could potentially try is:

import Spritz from 'spritz.js/dist/spritz.module.js'

Please let me know what the output is.

@vogloblinsky
Copy link
Author

ERROR in /home/SII/vogloblinsky/Documents/www/RetD/coding-game/coding-game-frontend/src/app/views/game/game.component.ts (3,20): Cannot find module 'spritz.js/dist/spritz.module.js'.)
webpack: Failed to compile.

@maoosi
Copy link
Owner

maoosi commented Feb 13, 2017

After having a little digging, the issue seems related with the way Typescript deals with modules import: microsoft/TypeScript#2719

I'm not sure if the problem really is with Typescript itself, or the tool I use to bundle the library (rollup). I don't personally use Typescript, but according the link above, one other way to write the fix you've found is:

import {default as Spritz} from "spritz.js";

@vogloblinsky
Copy link
Author

Nice, it works !
Thanks

@maoosi maoosi closed this as completed Feb 13, 2017
@vogloblinsky
Copy link
Author

Spoken too quickly.
Always same error :

ERROR in /home/SII/vogloblinsky/Documents/www/RetD/coding-game/coding-game-frontend/src/app/views/game/game.component.ts (3,20): Cannot find module 'spritz.js/dist/spritz.module.js'.)
webpack: Failed to compile.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants