Menci / vite-plugin-top-level-await

Transform code to support top-level await in normal browsers for Vite.
MIT License
250 stars 14 forks source link

Here is something wrong with 【npm/yarn/pnpn】 run 【dev/build】 #50

Open 12914hh opened 3 months ago

12914hh commented 3 months ago

This is My packjson "vite-plugin-top-level-await": "^1.4.1", And this is my vite.config.ts

import { fileURLToPath, URL } from 'node:url'

import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import topLevelAwait from 'vite-plugin-top-level-await'
import path from 'path'

export default defineConfig(({ mode }) => {
  const env = loadEnv(mode, __dirname)
  return {
    define: {
      'process.env': env,
    },
    plugins: [
      vue({
        template: {
          compilerOptions: {
            isCustomElement: (tag) => ['swiper-slide', 'swiper-container'].includes(tag),
          },
        },
        reactivityTransform: true,
      }),
      vueJsx(),
      topLevelAwait({
        // The export name of top-level await promise for each chunk module
        promiseExportName: '__tla',
        // The function to generate import names of top-level await promise in each chunk module
        promiseImportName: (i) => `__tla_${i}`,
      }),
    ],
    base: '/zwr/portal/',
    // logLevel: 'error',
    resolve: {
      alias: {
        '@': fileURLToPath(new URL('./src', import.meta.url)),
      },
    },
    server: {
      port: 3000,
      proxy: {
         .....
      },
    },
    css: {
      preprocessorOptions: {
        less: {
          modifyVars: {
            hack: `true; @import (reference) "${path.resolve('src/style/index.less')}";`,
          },
          javascriptEnabled: true,
        },
      },
    },
  }
})

image

But Yesterday ,everythings is ok,And the node_modules has this file。 image

What can I do for this? Thank you and Best wish~!

Menci commented 1 month ago

I have no idea of it. Could you please provide a reproduction?