empress / ember-cli-showdown

Ember component to render markdown into HTML.
https://empress.github.io/ember-cli-showdown/
MIT License
101 stars 35 forks source link

"showdown is not defined" #59

Closed wagenet closed 6 years ago

wagenet commented 6 years ago

Getting this in my tests with 4.0. 3.x works fine. I'm on the latest ember-cli.

testem.js:1025 ReferenceError: showdown is not defined
    at Class.<anonymous> (markdown-to-html.js:36)
    ...
jasonmit commented 6 years ago

@wagenet can you share which version of showdown and ember-cli your app targets?

wagenet commented 6 years ago

I was attempting to use the latest released version of both at the time I submitted the issue.

jasonmit commented 6 years ago

I haven't been able to reproduce this on the last version of ember-cli and showdown. I'll keep the issue opened for awhile in case anyone can reproduce.

wagenet commented 6 years ago

@jasonmit thanks for checking. I'll let you know if I encounter it again.

JackieChiles commented 6 years ago

I see this error on 4.x running ember-cli 2.14.x. Works fine on 3.x.

jasonmit commented 6 years ago

@JackieChiles I wasn't able to reproduce this against 2.14.0. Could you share all the immediate deps of your app?

npm ls --depth 0
jasonmit commented 6 years ago

@wagenet @JackieChiles can either of you verify that the showdown import existed at the top of your module? The breaking change between 3.0 and 4.0 was there was no longer a showdown global available.

wagenet commented 6 years ago

@jasonmit I don't have any extensions so importing shouldn't be necessary. showdown is never referenced in my source. The exception points back to https://github.com/gcollazo/ember-cli-showdown/blob/c021fa3565aacf941ca302864cd566f302a1e5d1/addon/components/markdown-to-html.js#L20. This is surprising, since the import is clearly there.

wagenet commented 6 years ago

Here's my nom ls --depth 0:

├── active-model-adapter@2.2.0
├── aws-sdk@2.188.0
├── babel-eslint@8.2.1
├── breakpoint-sass@2.7.1
├── broccoli-asset-rev@2.6.0
├── broccoli-static-compiler@0.2.2
├── broccoli-string-replace@0.1.2
├── connect-restreamer@1.0.3
├── d3@3.5.17
├── dotenv@4.0.0
├── ember-ajax@3.0.0
├── ember-cli@2.18.1
├── ember-cli-app-version@3.1.3
├── ember-cli-babel@6.11.0
├── ember-cli-clipboard@0.8.1
├── ember-cli-code-coverage@0.4.2
├── ember-cli-content-for-config@1.0.1
├── ember-cli-content-security-policy@1.0.0
├── ember-cli-dependency-checker@2.1.0
├── ember-cli-deploy@1.0.2
├── ember-cli-deploy-lightning-pack@1.2.0
├── ember-cli-deprecation-workflow@0.2.4
├── ember-cli-eslint@4.2.3
├── ember-cli-htmlbars@2.0.3
├── ember-cli-htmlbars-inline-precompile@1.0.2
├── ember-cli-inject-live-reload@1.7.0
├── ember-cli-inline-content@0.4.1
├── ember-cli-inline-images@0.0.4
├── ember-cli-mirage@0.4.1
├── ember-cli-moment-shim@3.5.0
├── ember-cli-qunit@4.0.2
├── ember-cli-release@0.2.9
├── ember-cli-sass@7.1.4
├── ember-cli-shims@1.2.0
├── ember-cli-showdown@4.1.1
├── ember-cli-sri@2.1.1
├── ember-cli-template-lint@0.7.5
├── ember-cli-uglify@2.0.0
├── ember-concurrency@0.8.14
├── ember-data@2.18.0
├── ember-disable-proxy-controllers@1.0.1
├── ember-elsewhere@1.0.3
├── ember-exam@1.0.0
├── ember-export-application-global@2.0.0
├── ember-freestyle@0.6.2
├── ember-href-to@1.15.1
├── ember-inflector@2.1.0
├── ember-load-initializers@1.0.0
├── ember-md5@1.0.1
├── ember-moment@7.6.0
├── ember-percy@1.2.22
├── ember-radio-buttons@4.1.0
├── ember-resolver@4.5.0
├── ember-sinon@1.0.1
├── ember-source@2.18.0
├── ember-svg-jar@0.12.0
├── ember-truth-helpers@2.0.0
├── ember-uuid@1.0.0
├── es5-shim@4.5.10
├── es6-shim@0.35.3
├── eslint@4.16.0
├── express@4.16.2
├── glob@7.1.2
├── highlightjs@9.10.0
├── jquery.payment@3.0.0
├── js-cookie@2.2.0
├── js-yaml@3.10.0
├── liquid-fire@0.29.1
├── loader.js@4.6.0
├── node-pre-gyp@0.6.39 extraneous
├── normalize.css@3.0.3
├── skylight-shared-assets@0.2.1 invalid
├── spin.js@2.3.2
├── sync-exec@0.6.2
└── testem@2.0.0
wagenet commented 6 years ago

I resolved it by adding app.import('node_modules/showdown/dist/showdown.js'); to my ember-cli-build.js. Not sure what's really correct here.

JackieChiles commented 6 years ago

Global showdown is also not referenced in my source.

jasonmit commented 6 years ago

resolved it by adding app.import('node_modules/showdown/dist/showdown.js');

Should not need to do this. If ember-cli-showdown was working correctly, it would do this for you.

If anyone can push an example to git that I can poke around to see what is wrong that would be super helpful. Otherwise, I'm pretty lost as I'm unable to reproduce this across a few apps.

mdbiscan commented 6 years ago

I can verify I'm getting this issue. I uninstalled version ~2.8.0 and re-installed as 4.3.0. Upgrading to Ember 2.10, was having issues with this component. Upgrading the component created the new error.

Verified that the Showdown module in bower_components is available, as ~1.3.0.

I've tried a few reinstalls, but the error is consistent.

loader.js:219 Uncaught Error: Could not find module 'showdown' imported from 'ember-cli-showdown/components/markdown-to-html'
jasonmit commented 6 years ago

Bower is no longer used with ember cli showdown, just npm. Any chance you can push a reproduction of this to github?

mdbiscan commented 6 years ago

I thought that may be the case. I removed it from Bower, but the same error occurs.

To reproduce:

I do see showdown installed in node_modules. However, when referencing showdown directly in an Ember component, I see the error.

This seems like an issue with showdown, though. I removed this plugin entirely, installed showdown directly, and I get an error when trying to import. Showdown's source files have conditions on it's exporting options. Perhaps its something within the environment.

ultimatelocal commented 6 years ago

Any update about this issue? Tried importing the showdown.js file on ember-cli-build.js but still the error persists.

jasonmit commented 6 years ago

Still cannot reproduce. Please push an example app to github that can reproduce the issue so I can fix it. screenshot_2018-05-10_20-11-58

jasonmit commented 6 years ago

Or if you have a lockfile, please post your package.json and lockfile - that may be all I need.

ultimatelocal commented 6 years ago

@jasonmit here's my package.json and package-lock.json. I just saved it on a text file since it's a lot of codes.

package.txt package-lock.txt

jasonmit commented 6 years ago

If you're on ember-cli < 2.16.0 then please target ember-showdown 3.x or upgrade your version of ember-cli. I'll update the README and include a build time assertion to prevent future trolling.

This is because 4.x depends on the relative new transformation API that landed in 2.16.0

wagenet commented 6 years ago

Still getting this on my app with the latest ember-cli. Also had to lock to 4.2 because 4.3 is giving me uglify errors.

jasonmit commented 6 years ago

Reopening in case someone wants to look into it.

wagenet commented 6 years ago

I will try to investigate more as well. I realize that it's near impossible for you to fix without a reproduction!

wagenet commented 6 years ago

AFAICT, this was related to something strange I was doing with asset handling. It's possible that what I was doing should be supported, but I've now refactored our asset handling and am no longer concerned about this issue. Thanks again for trying to figure it out!