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

[2.0.0] Impossible to use as a module? #83

Closed
dpogue opened this issue Feb 8, 2017 · 2 comments
Closed

[2.0.0] Impossible to use as a module? #83

dpogue opened this issue Feb 8, 2017 · 2 comments
Milestone

Comments

@dpogue
Copy link

dpogue commented Feb 8, 2017

Trying to pull the 2.0.0-beta.3 polyfill in to our project that uses TypeScript and WebPack2, and it seems effectively impossible to pull in as a module.

import 'drag-drop-polyfill';
DragDropPolyfill.Initialize(); // Compiler Error:
// error TS2304: Cannot find name 'DragDropPolyfill'.
import DragDropPolyfill from 'drag-drop-polyfill';
DragDropPolyfill.Initialize(); // Runtime Error:
// Uncaught TypeError: Cannot read property 'Initialize' of undefined
import * as DragDropPolyfill from 'drag-drop-polyfill';
DragDropPolyfill.Initialize(); // Runtime Error:
// Uncaught TypeError: DragDropPolyfill.Initialize is not a function

What is the proper way to use this with WebPack/Browserify/Rollup?

@reppners
Copy link
Collaborator

reppners commented Feb 9, 2017

UMD support is on the list but not yet implemented, as well as proper declaration file support on imports.

Personally I'm using it with SystemJS, the docs are off on the way to use it.

import "drag-drop-polyfill";

declare let DragDropPolyfill:any;

DragDropPolyfill.Initialize( {
    dragImageTranslateOverride: DragDropPolyfill.HandleDragImageTranslateOverride
} );

SystemJS takes care of loading files with global declarations properly. I don't know if and how WebPack is able to do this.

The plan is to migrate to TypeScript >2.0 which should result in proper UMD and declaration file support.

@reppners reppners added this to the 2.0.0 milestone Feb 17, 2017
@reppners reppners mentioned this issue May 26, 2017
3 tasks
reppners added a commit that referenced this issue Jun 4, 2017
* chore(deps): updates typescript and linter including needed changes

* refactor(DragDropPolyfill): utilize lib.d.ts definition for addEventListener

* WIP introduce rollup to generate UMD output and modify declaration files

* WIP umd suppport: update usage docs

* WIP umd suppport: add types field pointing to main declaration file

* WIP umd suppport: include sourcemaps

fixes #83, #94
@reppners
Copy link
Collaborator

reppners commented Jun 4, 2017

fixed by #100

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