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

fixed amd loader define to work on linux #2

Closed
wants to merge 1 commit into from

Conversation

luftj
Copy link

@luftj luftj commented Nov 19, 2019

The new module loader definition is in lower case, as follows:
define(["maptastic"], function() {
This is necessary, because linux (any unix?) uses this as a source path in node_modules/maptastic/dist/... and will fail during npm start since the previously used upper case identifier will not be found. Windows node seems to convert cases automatically.

I hope this fix won't break anyones import statements, my tests didn't indicate any problems so far.

@austince
Copy link
Owner

Hey thanks for the PR @luftj! Can you give me a little more info on how you’re using the package? What does your build system look like? Is there a way you could share a small example to reproduce the error?

@andredaa
Copy link

it is used inside this project : https://github.com/CityScope/CSL_Hamburg_Grasbrook

@luftj
Copy link
Author

luftj commented Dec 4, 2019

Hey thanks for the PR @luftj! Can you give me a little more info on how you’re using the package? What does your build system look like? Is there a way you could share a small example to reproduce the error?

We are working with angular 8. See this minimal example created with the angular CLI (I think you'd need to install it): https://github.com/luftj/maptastictest/tree/master
Install/build with npm i and run with npm start
This breaks on npm start with node 12 with Firefox on Arch Linux as well as Ubuntu with

ERROR in ./node_modules/maptastic/dist/maptastic.js
Module not found: Error: Can't resolve 'Maptastic' in '/home/.../maptastictest/node_modules/maptastic/dist'

on the branch https://github.com/luftj/maptastictest/tree/fix I install maptastic not from npm but from my PR-fork, and it works.

@austince
Copy link
Owner

austince commented Dec 4, 2019

Hey, thank you both for the info/ ways to reproduce - I've been extremely busy at work this week but hope to be able to run this within the week. Thanks for bearing with me, and after this is merged I'll be happy to make either/ both of you maintainers of this repo if you are interested.

@luftj
Copy link
Author

luftj commented Dec 7, 2019

Hey, thank you both for the info/ ways to reproduce - I've been extremely busy at work this week but hope to be able to run this within the week.

No worries, we've all been there :) And go there regularly...

Thanks for bearing with me, and after this is merged I'll be happy to make either/ both of you maintainers of this repo if you are interested.

Sure! I don't have experience, publishing to npm, but we use the maptastic functionality quite regularly.

@austince
Copy link
Owner

austince commented Dec 9, 2019

I think this is actually that the UMD loader doesn't support ESM modules, which is what Typescript is trying to load the file as. I've changed over to using Rollup to produce the UMD bundle and it seems to fix the issue (I can get a build on your test repo). Still a bit to do there to make it compatible with other loaders, but should be done/ published in the next day or two.

Sure! I don't have experience, publishing to npm, but we use the maptastic functionality quite regularly.

That's ok! I think it's great that you're using this and it's a low stakes package because you're likely the only ones. If you're up for using this a place to learn, you seem like you'd be an excellent maintainer.

@austince
Copy link
Owner

austince commented Dec 9, 2019

Please let me know if version 2.0.2 solves your problem! I ran it locally against the test repo and everything seemed to be happy.

@austince
Copy link
Owner

austince commented Dec 9, 2019

Also, do either of you @luftj @andredaa have any interest in helping out with #5?

@luftj
Copy link
Author

luftj commented Dec 10, 2019

Now it compiles but breaks when calling Maptastic()

ERROR ReferenceError: "numeric is not defined"
    anonymous http://localhost:4200/vendor.js line 84253 > Function:5
    LUsolve http://localhost:4200/vendor.js:86565
    solve http://localhost:4200/vendor.js:86596
    Y http://localhost:4200/vendor.js:82963
    s http://localhost:4200/vendor.js:82963
    Maptastic http://localhost:4200/vendor.js:82963
    maptasticMode http://localhost:4200/main.js:103
    View_AppComponent_0 ng:///AppModule/AppComponent.ngfactory.js:35
    handleEvent http://localhost:4200/vendor.js:74622
    callWithDebugContext http://localhost:4200/vendor.js:76241
    debugHandleEvent http://localhost:4200/vendor.js:75876
    dispatchEvent http://localhost:4200/vendor.js:61709
    renderEventHandlerClosure http://localhost:4200/vendor.js:73554
    decoratePreventDefault http://localhost:4200/vendor.js:79300
    invokeTask http://localhost:4200/polyfills.js:3397
    onInvokeTask http://localhost:4200/vendor.js:70625
    invokeTask http://localhost:4200/polyfills.js:3396
    runTask http://localhost:4200/polyfills.js:3174
    invokeTask http://localhost:4200/polyfills.js:3471
    invokeTask http://localhost:4200/polyfills.js:4609
    globalZoneAwareCallback http://localhost:4200/polyfills.js:4635

AppComponent.ngfactory.js:30:35

to reproduce, pull this, npm i, npm start, open localhost:4200 (default) and click on "TEST": https://github.com/luftj/maptastictest/commit/69d686a8c223d29bf6957663cf5fbfa60674cfd9

@austince
Copy link
Owner

austince commented Dec 10, 2019

Interesting, I'll see how that's being bundled. Not too familiar with how angular pulls in, but likely need to ship both an esm and umd module.

Update:
Looks like numeric is being included in the dependencies by angular/ webpack correctly, though the numeric itself is not finding its own reference.

@austince
Copy link
Owner

austince commented Dec 12, 2019

Looks like everyone is having similar issues with numeric:

A workaround for you in the short term would be to include numeric in your app HTML:

<script src="https://cdnjs.cloudflare.com/ajax/libs/numeric/1.2.6/numeric.js"></script>

@austince
Copy link
Owner

austince commented Dec 14, 2019

I have dropped the dependency that was having issues and published a new version (3.0.0). With this version, your demo seems to work well - the only change I had to make was using new Maptastic(...) vs just Maptastic(...).

Going to close this now, and I think it has been solved, but would still love to continue to see how you're using this + have you contribute (perhaps adding Typescript defs? #10).

Screen Shot 2019-12-14 at 5 03 56 PM

@austince austince closed this Dec 14, 2019
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

Successfully merging this pull request may close these issues.

3 participants