Polymer / pwa-starter-kit

Starter templates for building full-featured Progressive Web Apps from web components.
https://pwa-starter-kit.polymer-project.org
2.36k stars 431 forks source link

Promise rejection: Error: 'import' and 'export' may only appear at the top level #217

Closed budaii79 closed 6 years ago

budaii79 commented 6 years ago

Hello!

When I serve my app everything works fine. The problems occurs when I try to build my app. I do not understand what is happening and the log from npm is not helping me very much.

Could someone give me some hints where to start?

38828214_271747373636483_4378271618384789504_n

budaii79 commented 6 years ago

I tried with a clear clone of PWA starter Kit.First build was allright. After that I changed the page name NOT THE PATH in app.js and in actions/app.js from "view1" to "home". When I rebuilded the error was back. Tried to delete all build folders, error is still there. Did the undo to initial state. Error still there. Any toughts ?

davie-robertson commented 6 years ago

I can answer this one as it caught me out earlier this week when a colleague used a VS Code brackets prettyfier and it placed spaces after the import statements within the src/actions/app.js routing code

I guess you have the same plugin installed and it's doing a format on save.


        case 'view1':
            import ('../components/my-view1.js').then((module) => {
                // Put code in here that you want to run every time when
                // navigating to view1 after my-view1.js is loaded.
            });```
budaii79 commented 6 years ago

@davie-robertson Thank you very much my friend for the advice. It worked. When I think a spend a whole night for this! Thank you again and have a nice day!