Flow support
See original GitHub issueDescribe the bug
I’m trying to write vite-plugin for removing Flow.js types and i’m getting the error below
Reproduction
yarn create @vitejs/app
template - vanilla- (inside generated folder)
yarn install
yarn add -D flow-remove-types
- Set
main.js
content:
/* @flow */
type Type = {};
- 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,
};
},
},
],
};
yarn dev
// error
But it starts working if:
- Remove types from
main.js
- yarn dev
- 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)
- Run
vite
orvite 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.
- 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:
- Created 3 years ago
- Comments:18 (8 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
See @bunchtogether/vite-plugin-flow for flow support.
@wehriam Hey, did you already created a PR in https://github.com/vitejs/awesome-vite ?