AlexxNB / tinro

Highly declarative, tiny, dependency free router for Svelte's web applications.
MIT License
675 stars 30 forks source link

'hasContext' is not exported by node_modules\svelte\index.mjs #63

Closed olrtg closed 3 years ago

olrtg commented 3 years ago

Hi! I've wanted to try this package for a personal project using the svelte + electron template but I'm getting this error:

Error: 'hasContext' is not exported by node_modules\svelte\index.mjs, imported by node_modules\tinro\dist\tinro_lib.js
    at error (C:\Users\jolortegui\dev\soguer\node_modules\rollup\dist\shared\rollup.js:5206:30)
    at Module.error (C:\Users\jolortegui\dev\soguer\node_modules\rollup\dist\shared\rollup.js:9687:16)
    at handleMissingExport (C:\Users\jolortegui\dev\soguer\node_modules\rollup\dist\shared\rollup.js:9609:28)
    at Module.traceVariable (C:\Users\jolortegui\dev\soguer\node_modules\rollup\dist\shared\rollup.js:10082:24)
    at ModuleScope.findVariable (C:\Users\jolortegui\dev\soguer\node_modules\rollup\dist\shared\rollup.js:8631:39)
    at FunctionScope.findVariable (C:\Users\jolortegui\dev\soguer\node_modules\rollup\dist\shared\rollup.js:2762:38)
    at ChildScope.findVariable (C:\Users\jolortegui\dev\soguer\node_modules\rollup\dist\shared\rollup.js:2762:38)
    at Identifier$1.bind (C:\Users\jolortegui\dev\soguer\node_modules\rollup\dist\shared\rollup.js:4119:40)
    at Identifier$1.getReturnExpressionWhenCalledAtPath (C:\Users\jolortegui\dev\soguer\node_modules\rollup\dist\shared\rollup.js:4167:18)  
    at CallExpression$1.getReturnExpression (C:\Users\jolortegui\dev\soguer\node_modules\rollup\dist\shared\rollup.js:6757:57)

I think this is a problem with my rollup config but i cannot solve it so here's my rollup.config.js file in case anyone can help my with this.

import svelte from 'rollup-plugin-svelte'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import livereload from 'rollup-plugin-livereload'
import { terser } from 'rollup-plugin-terser'
import sveltePreprocess from 'svelte-preprocess'
import typescript from '@rollup/plugin-typescript'
import copy from 'rollup-plugin-copy'

const production = !process.env.ROLLUP_WATCH

function serve() {
  let server

  function toExit() {
    if (server) server.kill(0)
  }

  return {
    writeBundle() {
      if (server) return
      server = require('child_process').spawn(
        'npm',
        ['run', 'start', '--', '--dev'],
        {
          stdio: ['ignore', 'inherit', 'inherit'],
          shell: true,
        }
      )

      process.on('SIGTERM', toExit)
      process.on('exit', toExit)
    },
  }
}

export default {
  input: 'src/main.ts',
  output: {
    sourcemap: true,
    format: 'iife',
    name: 'app',
    file: 'public/build/bundle.js',
  },
  plugins: [
    svelte({
      // enable run-time checks when not in production
      dev: !production,
      // we'll extract any component CSS out into
      // a separate file - better for performance
      css: (css) => {
        css.write('public/build/bundle.css')
      },
      preprocess: sveltePreprocess({
        sourceMap: !production,
        postcss: true,
      }),
    }),

    // If you have external dependencies installed from
    // npm, you'll most likely need these plugins. In
    // some cases you'll need additional configuration -
    // consult the documentation for details:
    // https://github.com/rollup/plugins/tree/master/packages/commonjs
    resolve({
      browser: true,
      dedupe: ['svelte'],
    }),
    commonjs(),
    typescript({ sourceMap: !production }),
    copy({
      targets: [
        {
          src: [
            'public/fonts/**/*.eot',
            'public/fonts/**/*.svg',
            'public/fonts/**/*.ttf',
            'public/fonts/**/*.woff',
            'public/fonts/**/*.woff2',
          ],
          dest: 'public/build',
        },
      ],
    }),

    // In dev mode, call `npm run start` once
    // the bundle has been generated
    !production && serve(),

    // Watch the `public` directory and refresh the
    // browser on changes when not in production
    !production && livereload('public'),

    // If we're building for production (npm run build
    // instead of npm run dev), minify
    production && terser(),
  ],
  watch: {
    clearScreen: false,
  },
}

Greetings from Paraguay!

AlexxNB commented 3 years ago

Be sure, you are using latest Svelte version. 'hasContext' was added few versions ago.