logo
  • 現在做什麼
  • 關於我

Kalan

文章分類

  • 前端
  • 開發筆記
  • 雜談
  • 年度回顧

快速連結

  • 現在做什麼
  • 關於我
  • 聯絡我
  • 職涯思考🔗

關注我

在福岡生活的開發者,分享軟體開發與日本生活的點點滴滴。

© 2025 Kalan Made with ❤️. All rights reserved.

Rollup error encountered with Svelte with apollo-boost

Written byKalanKalanApr 25, 2020
Home/Frontend
💡

If you have any questions or feedback, pleasefill out this form

Japanese原文

Table of Contents

    This post is translated by ChatGPT and originally written in Mandarin, so there may be some inaccuracies or mistakes.

    I originally wanted to experiment with Svelte alongside GraphQL to see what the experience would be like. The Observable Query provided by Apollo is very easy to integrate into reactive scenarios.

    I imported ApolloClient in Svelte:

    import ApolloClient from 'apollo-boost';

    However, after everything was set up, I found that Rollup compilation failed:

    [!] Error: 'import' and 'export' may only appear at the top level
    node_modules/symbol-observable/es/index.js (2:0)
    1: /* global window */
    2: import ponyfill from './ponyfill.js';
       ^
    3:
    4: var root;
    Error: 'import' and 'export' may only appear at the top level
        at error (/Users/kalan/code/github-tool/node_modules/rollup/dist/shared/node-entry.js:5400:30)
        at Module.error (/Users/kalan/code/github-tool/node_modules/rollup/dist/shared/node-entry.js:9824:16)
        at tryParse (/Users/kalan/code/github-tool/node_modules/rollup/dist/shared/node-entry.js:9717:23)
        at Module.setSource (/Users/kalan/code/github-tool/node_modules/rollup/dist/shared/node-entry.js:10080:33)
        at Promise.resolve.catch.then.then.then (/Users/kalan/code/github-tool/node_modules/rollup/dist/shared/node-entry.js:12366:20)

    I looked up the issue and found that similar problems occur elsewhere. I'm currently not inclined to keep searching for a solution because I have other ideas I want to finish first. So, I’ll just return to my comfort zone and continue using React for now. I'll make a note of this and revisit it later.

    ← Svelte Notes (1) - No Silver BulletHow to record video using XCode Simulator →

    If you found this article helpful, please consider buying me a coffee ☕ It'll make my ordinary day shine ✨

    ☕Buy me a coffee