Skip to content

Error when building with a library polyfilling Symbol #4090

@pmk1c

Description

@pmk1c

Describe the bug

I tried to build a project with vite, where I was using @jumpn/utils-composite. Whenever I build this project and open the page I get the error "symbol is not a function".

It looks like there is an error transpiling the libraries code.

Reproduction

I created a test project with no changes to a vanilla vite project, but the one library import. The error is reproducable there. You can find it here: https://github.com/pmk1c/vite-test-symbol/blob/main/main.js

System Info

System:
    OS: macOS 11.4
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 104.66 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.16.1 - ~/.asdf/installs/nodejs/14.16.1/bin/node
    Yarn: 1.22.10 - ~/Projekte/node_modules/.bin/yarn
    npm: 7.17.0 - ~/.asdf/installs/nodejs/14.16.1/.npm/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Browsers:
    Chrome: 91.0.4472.114
    Firefox: 89.0.2
    Safari: 14.1.1
  npmPackages:
    vite: ^2.3.8 => 2.3.8

Used Package Manager

yarn

Logs

$ vite build --minify false --sourcemap true --debug
  vite:config no config file found. +0ms
  vite:config using resolved config: {
  vite:config   root: '/Users/***/Projekte/test-symbol',
  vite:config   base: '/',
  vite:config   mode: 'production',
  vite:config   configFile: undefined,
  vite:config   logLevel: undefined,
  vite:config   clearScreen: undefined,
  vite:config   build: {
  vite:config     target: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
  vite:config     polyfillDynamicImport: false,
  vite:config     outDir: 'dist',
  vite:config     assetsDir: 'assets',
  vite:config     assetsInlineLimit: 4096,
  vite:config     cssCodeSplit: true,
  vite:config     sourcemap: true,
  vite:config     rollupOptions: {},
  vite:config     commonjsOptions: { include: [Array], extensions: [Array] },
  vite:config     minify: false,
  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     watch: null
  vite:config   },
  vite:config   configFileDependencies: [],
  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     build: { minify: 'false', sourcemap: true }
  vite:config   },
  vite:config   resolve: { dedupe: undefined, alias: [ [Object] ] },
  vite:config   publicDir: '/Users/***/Projekte/test-symbol/public',
  vite:config   cacheDir: '/Users/***/Projekte/test-symbol/node_modules/.vite',
  vite:config   command: 'build',
  vite:config   isProduction: true,
  vite:config   plugins: [
  vite:config     'alias',
  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:build-html',
  vite:config     'commonjs',
  vite:config     'vite:data-uri',
  vite:config     'rollup-plugin-dynamic-import-variables',
  vite:config     'vite:import-analysis',
  vite:config     'vite:esbuild-transpile',
  vite:config     'vite:reporter'
  vite:config   ],
  vite:config   server: {
  vite:config     fsServe: { root: '/Users/***/Projekte/test-symbol', strict: false }
  vite:config   },
  vite:config   env: { BASE_URL: '/', MODE: 'production', DEV: false, PROD: true },
  vite:config   assetsInclude: [Function: assetsInclude],
  vite:config   logger: {
  vite:config     hasWarned: false,
  vite:config     info: [Function: info],
  vite:config     warn: [Function: warn],
  vite:config     warnOnce: [Function: warnOnce],
  vite:config     error: [Function: error],
  vite:config     clearScreen: [Function: clearScreen]
  vite:config   },
  vite:config   createResolver: [Function: createResolver],
  vite:config   optimizeDeps: { esbuildOptions: { keepNames: undefined } }
  vite:config } +5ms
vite v2.3.8 building for production...
✓ 245 modules transformed.
dist/index.html                  0.49kb
dist/assets/index.38b0c734.css   0.19kb / brotli: 0.12kb
dist/assets/index.62a613ad.js    0.40kb / brotli: 0.22kb
dist/assets/index.62a613ad.js.map 0.37kb
dist/assets/vendor.2f9ab7b8.js   52.06kb / brotli: 11.67kb
dist/assets/vendor.2f9ab7b8.js.map 112.53kb
✨  Done in 1.31s.

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug: upstreamBug in a dependency of ViteinconsistencyInconsistency between dev & build

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions