-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Closed
Labels
Description
Describe the bug
I want to build a TS file in lib mode for production. The code includes the use of the createServer module from Vite. When I try to build it, the build crashes
vite v2.9.5 building for production...
✓ 18 modules transformed.
[vite:worker-import-meta-url] can not match string template expression.
file: /Users/kpturner/fotech/vite-bug-minimal/node_modules/vite/dist/node/chunks/dep-27bc1ab8.js
error during build:
Error: can not match string template expression.
at error$3 (/Users/kpturner/fotech/vite-bug-minimal/node_modules/vite/dist/node/chunks/dep-27bc1ab8.js:26769:17)
at lexStringTemplateExpression (/Users/kpturner/fotech/vite-bug-minimal/node_modules/vite/dist/node/chunks/dep-27bc1ab8.js:26764:9)
at emptyString (/Users/kpturner/fotech/vite-bug-minimal/node_modules/vite/dist/node/chunks/dep-27bc1ab8.js:26685:28)
at Object.transform (/Users/kpturner/fotech/vite-bug-minimal/node_modules/vite/dist/node/chunks/dep-27bc1ab8.js:60804:37)
at /Users/kpturner/fotech/vite-bug-minimal/node_modules/rollup/dist/shared/rollup.js:22823:37
Reproduction
https://github.com/kpturner/vite-bug-minimal
System Info
System:
OS: macOS 11.6.4
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 2.37 GB / 16.00 GB
Shell: 5.8 - /usr/local/bin/zsh
Binaries:
Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node
npm: 8.1.2 - ~/.nvm/versions/node/v16.13.1/bin/npm
Browsers:
Chrome: 100.0.4896.127
Edge: 100.0.1185.39
Firefox: 96.0.3
Safari: 15.3
npmPackages:
vite: 2.9.5 => 2.9.5Used Package Manager
npm
Logs
vite:config bundled config file loaded in 70.52ms +0ms
vite:config using resolved config: {
vite:config plugins: [
vite:config 'vite:build-metadata',
vite:config 'alias',
vite:config 'vite:modulepreload-polyfill',
vite:config 'vite:resolve',
vite:config 'vite:html-inline-proxy',
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 'vite:worker-import-meta-url',
vite:config 'vite:watch-package-data',
vite:config 'commonjs',
vite:config 'vite:data-uri',
vite:config 'rollup-plugin-dynamic-import-variables',
vite:config 'vite:asset-import-meta-url',
vite:config 'vite:build-import-analysis',
vite:config 'vite:esbuild-transpile',
vite:config 'vite:reporter',
vite:config 'vite:load-fallback'
vite:config ],
vite:config resolve: { dedupe: undefined, alias: [ [Object], [Object], [Object] ] },
vite:config build: {
vite:config target: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
vite:config polyfillModulePreload: true,
vite:config outDir: 'dist',
vite:config assetsDir: 'assets',
vite:config assetsInlineLimit: 4096,
vite:config cssCodeSplit: false,
vite:config cssTarget: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
vite:config sourcemap: false,
vite:config rollupOptions: { output: {} },
vite:config minify: false,
vite:config terserOptions: {},
vite:config write: true,
vite:config emptyOutDir: false,
vite:config manifest: false,
vite:config lib: {
vite:config entry: '/Users/kpturner/fotech/vite-bug-minimal/server.ts',
vite:config name: 'EntryServer',
vite:config fileName: [Function: fileName]
vite:config },
vite:config ssr: false,
vite:config ssrManifest: false,
vite:config reportCompressedSize: true,
vite:config chunkSizeWarningLimit: 500,
vite:config watch: null,
vite:config commonjsOptions: { include: [Array], extensions: [Array] },
vite:config dynamicImportVarsOptions: { warnOnError: true, exclude: [Array] }
vite:config },
vite:config configFile: '/Users/kpturner/fotech/vite-bug-minimal/vite.config.ts',
vite:config configFileDependencies: [ '/Users/kpturner/fotech/vite-bug-minimal/vite.config.ts' ],
vite:config inlineConfig: {
vite:config root: undefined,
vite:config base: undefined,
vite:config mode: undefined,
vite:config configFile: './vite.config.ts',
vite:config logLevel: undefined,
vite:config clearScreen: undefined,
vite:config build: {}
vite:config },
vite:config root: '/Users/kpturner/fotech/vite-bug-minimal',
vite:config base: '/',
vite:config publicDir: '/Users/kpturner/fotech/vite-bug-minimal/public',
vite:config cacheDir: '/Users/kpturner/fotech/vite-bug-minimal/node_modules/.vite',
vite:config command: 'build',
vite:config mode: 'production',
vite:config isWorker: false,
vite:config isProduction: true,
vite:config server: {
vite:config preTransformRequests: true,
vite:config fs: { strict: true, allow: [Array], deny: [Array] }
vite:config },
vite:config preview: {
vite:config port: undefined,
vite:config strictPort: undefined,
vite:config host: undefined,
vite:config https: undefined,
vite:config open: undefined,
vite:config proxy: undefined,
vite:config cors: undefined,
vite:config headers: undefined
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 hasErrorLogged: [Function: hasErrorLogged]
vite:config },
vite:config packageCache: Map(0) { set: [Function (anonymous)] },
vite:config createResolver: [Function: createResolver],
vite:config optimizeDeps: {
vite:config esbuildOptions: { keepNames: undefined, preserveSymlinks: undefined }
vite:config },
vite:config worker: {
vite:config format: 'iife',
vite:config plugins: [
vite:config [Object], [Object], [Object],
vite:config [Object], [Object], [Object],
vite:config [Object], [Object], [Object],
vite:config [Object], [Object], [Object],
vite:config [Object], [Object], [Object],
vite:config [Object], [Object], [Object],
vite:config [Object], [Object], [Object],
vite:config [Object], [Object], [Object]
vite:config ],
vite:config rollupOptions: {}
vite:config }
vite:config } +13ms
vite v2.9.5 building for production...
✓ 18 modules transformed.
[vite:worker-import-meta-url] can not match string template expression.
file: /Users/kpturner/fotech/vite-bug-minimal/node_modules/vite/dist/node/chunks/dep-27bc1ab8.js
error during build:
Error: can not match string template expression.
at error$3 (/Users/kpturner/fotech/vite-bug-minimal/node_modules/vite/dist/node/chunks/dep-27bc1ab8.js:26769:17)
at lexStringTemplateExpression (/Users/kpturner/fotech/vite-bug-minimal/node_modules/vite/dist/node/chunks/dep-27bc1ab8.js:26764:9)
at emptyString (/Users/kpturner/fotech/vite-bug-minimal/node_modules/vite/dist/node/chunks/dep-27bc1ab8.js:26685:28)
at Object.transform (/Users/kpturner/fotech/vite-bug-minimal/node_modules/vite/dist/node/chunks/dep-27bc1ab8.js:60804:37)
at /Users/kpturner/fotech/vite-bug-minimal/node_modules/rollup/dist/shared/rollup.js:22823:37Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.