static-dev / spike

A modern static build tool, powered by webpack
http://spike.js.org
Other
470 stars 29 forks source link

Fails with third-party pug code: TypeError: Cannot read property 'line' of undefined #85

Closed maotora closed 6 years ago

maotora commented 6 years ago

Hello,

I'm including a pug code which looks exactly like sgr code but it keeps on failing with error

✗ ERROR
{ ModuleBuildError: Module build failed: TypeError: Cannot read property 'line' of undefined
    at new ReshapeError (/home/user/Projects/Sites/archnoob/node_modules/reshape/lib/error.js:8:33)
    at new ReshapePluginError (/home/user/Projects/Sites/archnoob/node_modules/reshape/lib/error.js:43:28)
    at mergeExtendsAndLayout (/home/user/Projects/Sites/archnoob/node_modules/reshape-layouts/lib/index.js:84:11)
    at tree.reduce (/home/user/Projects/Sites/archnoob/node_modules/reshape-layouts/lib/index.js:54:18)
    at Array.reduce (<anonymous>)
    at handleExtendsNodes (/home/user/Projects/Sites/archnoob/node_modules/reshape-layouts/lib/index.js:26:15)
    at layoutsPlugin (/home/user/Projects/Sites/archnoob/node_modules/reshape-layouts/lib/index.js:16:12)
    at W.reduce (/home/user/Projects/Sites/archnoob/node_modules/reshape/lib/index.js:47:60)
    at tryCatchResolve (/home/user/Projects/Sites/archnoob/node_modules/when/lib/apply.js:46:23)
    at callAndResolve (/home/user/Projects/Sites/archnoob/node_modules/when/lib/apply.js:30:12)
    at runLoaders (/home/user/Projects/Sites/archnoob/node_modules/webpack/lib/NormalModule.js:195:19)
    at /home/user/Projects/Sites/archnoob/node_modules/loader-runner/lib/LoaderRunner.js:364:11
    at /home/user/Projects/Sites/archnoob/node_modules/loader-runner/lib/LoaderRunner.js:230:18
    at context.callback (/home/user/Projects/Sites/archnoob/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
    at tryCatchReject (/home/user/Projects/Sites/archnoob/node_modules/when/lib/makePromise.js:845:30)
    at runContinuation1 (/home/user/Projects/Sites/archnoob/node_modules/when/lib/makePromise.js:804:4)
    at Rejected.when (/home/user/Projects/Sites/archnoob/node_modules/when/lib/makePromise.js:625:4)
    at Pending.run (/home/user/Projects/Sites/archnoob/node_modules/when/lib/makePromise.js:483:13)
    at Scheduler._drain (/home/user/Projects/Sites/archnoob/node_modules/when/lib/Scheduler.js:62:19)
    at Scheduler.drain (/home/user/Projects/Sites/archnoob/node_modules/when/lib/Scheduler.js:27:9) id: '7608ad6d' }

The pug code included in my layout.sgr file for simplicity.

doctype html
html
  head
    meta(charset='utf-8')
    meta(http-equiv='X-UA-Compatible' content='IE=edge')
    meta(name='description' content='')
    meta(name='author' content='maotora')
    meta(name='viewport' content='width=device-width, initial-scale=1')

    block(name='title')
      title Welcome To ArchNoob

    link(rel='stylesheet' href='css/index.css')

  body
    main(role='main' id='{{ pageId }}')
        section.pug_code
            section.stackoverflow_badge
                .so-card
                    a(href="https://stackoverflow.com/users/2405689/archnoob", target="_blank").so-profile-link

                .so-header
                    span.so-logo
                    img(src="http://cdn.sstatic.net/stackexchange/img/logos/so/so-icon.png")
                    .so-profile-picture-container
                    img(src="https://www.gravatar.com/avatar/10940e5ff8f37a7cd084f0cbceac74a2?s=128&d=identicon&r=PG")
                    h4.so-display-name Mudassir Ali

                .so-content
                    p.so-reputation 3476
                    small.so-reputation-label Stackoverflow reputation

                .so-footer
                    span.so-badges-label Badges
                    span.so-badge-wrapper
                    span.so-badge.so-badge-gold
                    span.so-badge-count 0
                    span.so-badge-wrapper
                    span.so-badge.so-badge-silver
                    span.so-badge-count 10
                    span.so-badge-wrapper
                    span.so-badge.so-badge-bronze
                    span.so-badge-count 34

    block(name='javascript')
      script(src='js/main.js' defer)

I had to include it in the layout.sgr to see the error otherwise it was just rendering fine but none of the third-party pug code got rendered to the browser.

I found this code here and it works okay as I even tried it in another pug - html converter.

maotora commented 6 years ago

I hate when this happens.

Not sure what I did but to my surprise, it works now.

I removed most of the code and included it and now it works.

jescalan commented 6 years ago

👍 - be careful with pasting in pug code too, while similar, sugarml is not pug-compatible

maotora commented 6 years ago

@jescalan Nice to know that.

Thanks.

maotora commented 6 years ago

@jescalan hey man I just finished designing the website (alpha release) but thought it'll be better to share it for you to check it out.

I love it's caching capabilities & speed. https://archnoob.com

Thanks a lot.

jescalan commented 6 years ago

Awesome, great work my man! Looks fantastic ✨

maotora commented 6 years ago

Thank you very much, man.

I wouldn't have done such a great job if it wasn't for u and your team.

Cheers!