question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Describe the bug

I’m trying to write vite-plugin for removing Flow.js types and i’m getting the error below

Reproduction

  1. yarn create @vitejs/app template - vanilla
  2. (inside generated folder)
yarn install
yarn add -D flow-remove-types
  1. Set main.js content:
/* @flow */

type Type = {};
  1. Create vite.config.js:
import removeTypes from "flow-remove-types";

export default {
  plugins: [
    {
      name: "vite-plugin-flow",
      enforce: "pre",
      transform(code) {
        const output = removeTypes(code);

        return {
          code: output.toString(),
          map: null,
        };
      },
    },
  ],
};
  1. yarn dev // error

But it starts working if:

  1. Remove types from main.js
  2. yarn dev
  3. Add types to main.js

Sorry if i missed something in the docs.

System Info

  • vite version: 2.0.3
  • Operating System: Ubuntu 18.04
  • Node version: 14.15.4
  • Package manager (npm/yarn/pnpm) and version: yarn@1.22.5

Logs (Optional if provided reproduction)

  1. Run vite or vite build with the --debug flag.
  vite:config bundled config file loaded in 122ms +0ms
  vite:config using resolved config: {
  vite:config   plugins: [
  vite:config     'vite:pre-alias',
  vite:config     'alias',
  vite:config     'vite-plugin-flow',
  vite:config     'vite:dynamic-import-polyfill',
  vite:config     'vite:resolve',
  vite:config     'vite:html',
  vite:config     'vite:css',
  vite:config     'vite:esbuild',
  vite:config     'vite:json',
  vite:config     'vite:wasm',
  vite:config     'vite:worker',
  vite:config     'vite:asset',
  vite:config     'vite:define',
  vite:config     'vite:css-post',
  vite:config     'vite:client-inject',
  vite:config     'vite:import-analysis'
  vite:config   ],
  vite:config   server: {},
  vite:config   configFile: '/home/eazymov/Documents/projects/test/vite.config.js',
  vite:config   inlineConfig: {
  vite:config     root: undefined,
  vite:config     base: undefined,
  vite:config     mode: undefined,
  vite:config     configFile: undefined,
  vite:config     logLevel: undefined,
  vite:config     clearScreen: undefined,
  vite:config     server: {}
  vite:config   },
  vite:config   root: '/home/eazymov/Documents/projects/test',
  vite:config   base: '/',
  vite:config   resolve: { dedupe: undefined, alias: [ [Object] ] },
  vite:config   publicDir: '/home/eazymov/Documents/projects/test/public',
  vite:config   command: 'serve',
  vite:config   mode: 'development',
  vite:config   isProduction: false,
  vite:config   optimizeCacheDir: '/home/eazymov/Documents/projects/test/node_modules/.vite',
  vite:config   build: {
  vite:config     target: [ 'es2019', 'edge16', 'firefox60', 'chrome61', 'safari11' ],
  vite:config     polyfillDynamicImport: true,
  vite:config     outDir: 'dist',
  vite:config     assetsDir: 'assets',
  vite:config     assetsInlineLimit: 4096,
  vite:config     cssCodeSplit: true,
  vite:config     sourcemap: false,
  vite:config     rollupOptions: {},
  vite:config     commonjsOptions: { include: [Array], extensions: [Array] },
  vite:config     minify: 'terser',
  vite:config     terserOptions: {},
  vite:config     cleanCssOptions: {},
  vite:config     write: true,
  vite:config     emptyOutDir: null,
  vite:config     manifest: false,
  vite:config     lib: false,
  vite:config     ssr: false,
  vite:config     ssrManifest: false,
  vite:config     brotliSize: true,
  vite:config     chunkSizeWarningLimit: 500
  vite:config   },
  vite:config   env: { BASE_URL: '/', MODE: 'development', DEV: true, PROD: false },
  vite:config   assetsInclude: [Function: assetsInclude],
  vite:config   logger: {
  vite:config     hasWarned: false,
  vite:config     info: [Function: info],
  vite:config     warn: [Function: warn],
  vite:config     error: [Function: error],
  vite:config     clearScreen: [Function: clearScreen]
  vite:config   },
  vite:config   createResolver: [Function: createResolver]
  vite:config } +2ms
  vite:deps Crawling dependencies using entries:
  vite:deps   /home/eazymov/Documents/projects/test/index.html +0ms
  vite:resolve 1ms   /main.js -> /home/eazymov/Documents/projects/test/main.js +0ms
 > main.js:3:5: error: Expected ";" but found "Type"
    3 │ type Type = {};
      ╵      ~~~~

error when starting dev server:
Error: Build failed with 1 error:
main.js:3:5: error: Expected ";" but found "Type"
    at failureErrorWithLog (/home/eazymov/Documents/projects/test/node_modules/esbuild/lib/main.js:1171:15)
    at buildResponseToResult (/home/eazymov/Documents/projects/test/node_modules/esbuild/lib/main.js:907:32)
    at /home/eazymov/Documents/projects/test/node_modules/esbuild/lib/main.js:1002:20
    at /home/eazymov/Documents/projects/test/node_modules/esbuild/lib/main.js:553:9
    at handleIncomingPacket (/home/eazymov/Documents/projects/test/node_modules/esbuild/lib/main.js:642:9)
    at Socket.readFromStdout (/home/eazymov/Documents/projects/test/node_modules/esbuild/lib/main.js:520:7)
    at Socket.emit (events.js:315:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at Socket.Readable.push (internal/streams/readable.js:223:10)
error Command failed with exit code 1.
  1. Provide the error log here.
$ vite
 > main.js:3:5: error: Expected ";" but found "Type"
    3 │ type Type = {};
      ╵      ~~~~

error when starting dev server:
Error: Build failed with 1 error:
main.js:3:5: error: Expected ";" but found "Type"
    at failureErrorWithLog (/home/eazymov/Documents/projects/test/node_modules/esbuild/lib/main.js:1171:15)
    at buildResponseToResult (/home/eazymov/Documents/projects/test/node_modules/esbuild/lib/main.js:907:32)
    at /home/eazymov/Documents/projects/test/node_modules/esbuild/lib/main.js:1002:20
    at /home/eazymov/Documents/projects/test/node_modules/esbuild/lib/main.js:553:9
    at handleIncomingPacket (/home/eazymov/Documents/projects/test/node_modules/esbuild/lib/main.js:642:9)
    at Socket.readFromStdout (/home/eazymov/Documents/projects/test/node_modules/esbuild/lib/main.js:520:7)
    at Socket.emit (events.js:315:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at Socket.Readable.push (internal/streams/readable.js:223:10)
error Command failed with exit code 1.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
wehriamcommented, Jun 17, 2021

See @bunchtogether/vite-plugin-flow for flow support.

1reaction
Shinigami92commented, Jun 17, 2021

@wehriam Hey, did you already created a PR in https://github.com/vitejs/awesome-vite ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Flow Support Center
Phone Support (only for hosts/presenters): +1 415.394.8010, M-F 8 AM to 5 PM US Central. Home · Knowledge base · Submit a ticket....
Read more >
Flow Support
Hi. How can we help? Guide: getting started with Flow? Browse knowledge base. User Guide · Downloads · Troubleshooting.
Read more >
Support - Find all the help you need | Flow Jamaica
Call Us 1-800-804-2994. ... Visit a Flow Store. Or talk to your local sales rep. ... Hi there! How can I help you?...
Read more >
Flow Help
Promoted articles. Flow X – Answers to your most common questions around the launch. Help with Flow.
Read more >
FlowCare Service - Genuine Flow Waterjet Support
Contact Flow Service · Call: 1.800.526.4810 · Schedule Your Next Service · Meet Your Waterjet Team.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found