Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when outfile format cjs,vue style lose from dynamic import #27

Closed
6 tasks done
Veiintc opened this issue Jul 16, 2021 · 14 comments
Closed
6 tasks done

when outfile format cjs,vue style lose from dynamic import #27

Veiintc opened this issue Jul 16, 2021 · 14 comments
Labels
invalid This doesn't seem right

Comments

@Veiintc
Copy link

Veiintc commented Jul 16, 2021

Describe the bug

image
vitejs/vite#3101 had fixed for es,but cjs not
and How can I clean b_vue_vue_type_style_index_0_scoped_true_lang?

Reproduction

https://github.com/Veiintc/vite-cjs-csslose.git

System Info

System:
    OS: Windows 10 10.0.19042
    CPU: (8) x64 Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
    Memory: 2.98 GB / 15.83 GB
  Binaries:
    Node: 14.6.0 - D:\Program Files\nodejs\node.EXE
    npm: 6.14.6 - D:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1023.0), Chromium (91.0.864.64)
    Internet Explorer: 11.0.19041.1

Used Package Manager

npm

Logs

vite:config bundled config file loaded in 153ms +0ms
  vite:config using resolved config: {
  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: false,
  vite:config     rollupOptions: { output: [Object] },
  vite:config     commonjsOptions: { include: [Array], extensions: [Array] },
  vite:config     dynamicImportVarsOptions: { warnOnError: true, exclude: [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   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:vue',
  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     'asset-import-meta-url',
  vite:config     'vite:import-analysis',
  vite:config     'vite:esbuild-transpile',
  vite:config     'vite:reporter'
  vite:config   ],
  vite:config   define: { __VUE_OPTIONS_API__: true, __VUE_PROD_DEVTOOLS__: false },
  vite:config   ssr: { external: [ 'vue', '@vue/server-renderer' ] },
  vite:config   configFile: 'D:/Program Files/test/vite-preload-dep/vite.config.js',
  vite:config   configFileDependencies: [ '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     build: {}
  vite:config   },
  vite:config   root: 'D:/Program Files/test/vite-preload-dep',
  vite:config   base: '/',
  vite:config   resolve: { dedupe: undefined, alias: [ [Object] ] },
  vite:config   publicDir: 'D:\\Program Files\\test\\vite-preload-dep\\public',
  vite:config   cacheDir: 'D:\\Program Files\\test\\vite-preload-dep\\node_modules\\.vite',
  vite:config   command: 'build',
  vite:config   mode: 'production',
  vite:config   isProduction: true,
  vite:config   server: { fs: { strict: undefined, allow: [Array] } },
  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 } +8ms

Validations

@Veiintc

This comment was marked as spam.

1 similar comment
@Veiintc

This comment was marked as spam.

@Shinigami92
Copy link
Member

@Veiintc Do you ask for a help wanted label? Or do you want to try to tackle it on your own?

@Veiintc
Copy link
Author

Veiintc commented Sep 15, 2021

Is this a low priority issue?

@Shinigami92
Copy link
Member

Is this a low priority issue?

I'm not sure right now. I'm not as deep into it and know what is happening here, so I cannot assign a label like p3 or p4 or p5.
So until no other team member comes along this issue you are waiting on the community to take any action.
Please note that the vite team itself doesn't fix any bugs directly unless it is a really high prio. We are more moderators and try to help the community to fix and implement stuff with e.g. reviews and suggestions.

@KamilOcean
Copy link

Is this a low priority issue?

Hi, @Veiintc can you explain an expected behaviour, please? Do you expect "CJS" CommonJS module to be in your build or what? And why you marked the CSS file on your screenshot?

Thanks a lot

@Veiintc
Copy link
Author

Veiintc commented Sep 15, 2021

Is this a low priority issue?

Hi, @Veiintc can you explain an expected behaviour, please? Do you expect "CJS" CommonJS module to be in your build or what? And why you marked the CSS file on your screenshot?

Thanks a lot

it seems my description is not accurate enough,
like 3101,when format cjs,I will lose vue style
and I can not find anywhere had import this css file

@KamilOcean
Copy link

@Veiintc gotta. I think I get you. I opened your reproduction repo. As I understand you can't find styles from your common.module.less file in your prod build??

If I get you right and it is.

So, you don't include your CSS module file in your project and the needed styles will NOT be in your prod build. Now they are unused and they don't have to be in your build. They are not in the module graph.

I added this script line in your component b.vue

<template>
  <h2>Scan Deps from &lt;script setup lang=ts&gt; blocks</h2>
  <div class="scan">{{ typeof debounce === 'function' ? 'ok' : 'error' }}</div>
</template>

<script>
import classes from './common.module.less'
</script>

<style lang="less" scoped>
.scan{
  color: blue;
}

</style>

And now I can see the needed styles in my final production build by executing the command yarn build

._root_xlv1v_1 {
  color: red;
}
.scan[data-v-4e39fff2] {
  color: blue;
}

@Veiintc
Copy link
Author

Veiintc commented Sep 16, 2021

@Veiintc gotta. I think I get you. I opened your reproduction repo. As I understand you can't find styles from your file in your prod build??common.module.less

If I get you right and it is.

So, you don't include your CSS module file in your project and the needed styles will NOT be in your prod build. Now they are unused and they don't have to be in your build. They are not in the module graph.

I added this script line in your component b.vue

<template>
  <h2>Scan Deps from &lt;script setup lang=ts&gt; blocks</h2>
  <div class="scan">{{ typeof debounce === 'function' ? 'ok' : 'error' }}</div>
</template>

<script>
import classes from './common.module.less'
</script>

<style lang="less" scoped>
.scan{
  color: blue;
}

</style>

And now I can see the needed styles in my final production build by executing the command yarn build

._root_xlv1v_1 {
  color: red;
}
.scan[data-v-4e39fff2] {
  color: blue;
}

Thank you for your reply,
But the problem is that the blue style has not been introduced
Although the file was generated, it was not introduced
image

@Veiintc
Copy link
Author

Veiintc commented Sep 16, 2021

and when at vite 2.1.5,it will create style label
image

@KamilOcean
Copy link

and when at vite 2.1.5,it will create style label
image

I have Vite 2.4.2 and I see applied styles
image

@Veiintc
Copy link
Author

Veiintc commented Sep 16, 2021

are you format cjs?
if you format es ,It had fixed

@KamilOcean
Copy link

are you format cjs?
if you format es ,It had fixed

Man, I just run your project, that you provided. Where is the file in CJS format? I don't understand

@Veiintc
Copy link
Author

Veiintc commented Sep 16, 2021

are you format cjs?
if you format es ,It had fixed

Man, I just run your project, that you provided. Where is the file in CJS format? I don't understand

are you run dev ?
build outfile format cjs,it not run in browser。

@patak-dev patak-dev transferred this issue from vitejs/vite Dec 3, 2022
@edison1105 edison1105 added invalid This doesn't seem right and removed pending triage labels Sep 25, 2024
@vitejs vitejs locked and limited conversation to collaborators Sep 25, 2024
@edison1105 edison1105 converted this issue into discussion #454 Sep 25, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
invalid This doesn't seem right
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants