core icon indicating copy to clipboard operation
core copied to clipboard

[Bug report] TypeError: Invalid value used as weak map key

Open Flagrare opened this issue 5 years ago • 9 comments

I don't know that is causing the error when I try to build the application. I don't have any deprecated tags.

I have a very complex documentation. The only custom thing I have is a component that is wrapping Swagger UI. Other than that, I cannot think of anything that could be breaking the build.

<template>
    <div class="swagger" id="swagger"></div>
</template>

<script>
import SwaggerUI from 'swagger-ui';
import 'swagger-ui/dist/swagger-ui.css';

export default {
    name: "Swagger",
    mounted() {
        const spec = require('../public/specs/openapi-schema.json');
        SwaggerUI({
            spec: spec,
            dom_id: '#swagger'
        })
    }
}
</script>
<style>
html.dark .swagger-ui {
    filter: invert(88%) hue-rotate(180deg);
}

html.dark .swagger-ui .highlight-code {
    filter: invert(100%) hue-rotate(180deg);
}

html.dark .swagger-ui pre.version{
    background-color: transparent;
}
html.dark .swagger-ui div.scheme-container{
    background-color: white !important;
}

html.dark .swagger-ui tr:nth-child(even) {
    background-color: #f2f2f2;
}
</style>

Screenshots

Captura de Tela 2021-08-26 às 02 15 26

Environment info

  • Browser: Chrome
  • Output of vuepress info:
  System:
    OS: macOS 11.4
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 23.87 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.15.0 - ~/.nvm/versions/node/v14.15.0/bin/node
    Yarn: 1.22.10 - ~/.nvm/versions/node/v14.15.0/bin/yarn
    npm: 6.14.8 - ~/.nvm/versions/node/v14.15.0/bin/npm
  Utilities:
    Git: 2.30.1 - /usr/bin/git
  Browsers:
    Chrome: 92.0.4515.159
    Edge: Not Found
    Firefox: 91.0.2
    Safari: 14.1.1
  npmPackages:
    @vuepress/bundler-vite: Not Found
    @vuepress/bundler-webpack:  2.0.0-beta.21 
    @vuepress/cli:  2.0.0-beta.21 
    @vuepress/client:  2.0.0-beta.21 (2.0.0-beta.23)
    @vuepress/core:  2.0.0-beta.21 (2.0.0-beta.23)
    @vuepress/markdown:  2.0.0-beta.21 (2.0.0-beta.23)
    @vuepress/plugin-active-header-links:  2.0.0-beta.21 
    @vuepress/plugin-back-to-top:  2.0.0-beta.21 
    @vuepress/plugin-container:  2.0.0-beta.21 
    @vuepress/plugin-debug: Not Found
    @vuepress/plugin-docsearch: Not Found
    @vuepress/plugin-git:  2.0.0-beta.21 
    @vuepress/plugin-google-analytics: Not Found
    @vuepress/plugin-medium-zoom:  2.0.0-beta.21 
    @vuepress/plugin-nprogress:  2.0.0-beta.21 
    @vuepress/plugin-palette:  2.0.0-beta.21 
    @vuepress/plugin-prismjs:  2.0.0-beta.21 
    @vuepress/plugin-pwa: Not Found
    @vuepress/plugin-pwa-popup: Not Found
    @vuepress/plugin-register-components: 2.0.0-beta.23 => 2.0.0-beta.23 
    @vuepress/plugin-search: ^2.0.0-beta.21 => 2.0.0-beta.21 
    @vuepress/plugin-shiki: Not Found
    @vuepress/plugin-theme-data:  2.0.0-beta.21 
    @vuepress/plugin-toc: Not Found
    @vuepress/shared:  2.0.0-beta.21 (2.0.0-beta.23)
    @vuepress/theme-default:  2.0.0-beta.21 
    @vuepress/utils:  2.0.0-beta.21 (2.0.0-beta.23)
    vue:  3.1.4 (3.2.4)
    vue-loader:  16.3.0 
    vue-router:  4.0.10 
    vuepress: ^2.0.0-beta.21 => 2.0.0-beta.21 
    vuepress-vite: Not Found

Flagrare avatar Aug 26 '21 05:08 Flagrare

This is a vue issue. Vue do not allow to use any unknown tags. Any of that would be regarded as vue components.

The package you are importing is likely to create some of that(deprecated html tag or custom elements). Please review it in your devServer to check out.

Then add those tags with this config, to make sure @vue/compiler leave it as is.

https://v3.vuejs.org/api/application-config.html#compileroptions-iscustomelement

Mister-Hope avatar Aug 26 '21 05:08 Mister-Hope

I have seen this option, but I have no idea how to use this option in my project. Should I use it on my custom component? I am not very familiar with Vue.

Anyway I deleted the component and the problem still persists.

Flagrare avatar Aug 26 '21 05:08 Flagrare

https://vuepress2.netlify.app/reference/bundler/webpack.html#vue

https://vuepress2.netlify.app/reference/bundler/vite.html#vuepluginoptions

No offense, but you should check the docs carefully.

If you are not familiar with Vue, I personally recomand you not to import 3rd party code which may need extra handling to work with vue. Especially those who operate dom directly, which obey the mvvm design.

I would assume you know what's SSR, so anything you imported should work with ssr rending with vue-laoder in such a project like vuepress.

Mister-Hope avatar Aug 26 '21 05:08 Mister-Hope

Hi, Mister-Hope, like I said, I removed aforementioned element and the problem still persists and I cannot find the reason why. Any tips?

Flagrare avatar Aug 26 '21 14:08 Flagrare

Nope, suggesting to create a minimal reproduction. Maybe meteorlxy will review it if he has time.

Mister-Hope avatar Aug 26 '21 16:08 Mister-Hope

Anyway, we could not figure out the issue from the limited description. A reproduce repo is necessary.

meteorlxy avatar Aug 27 '21 04:08 meteorlxy

Hello @Flagrare. Please provide a minimal reproduction using a GitHub repository or codesandbox. Issues marked with need reproduction will be closed if they have no activity within 3 days.

github-actions[bot] avatar Aug 27 '21 04:08 github-actions[bot]

We can close the issue, I started a project from scratch and copied all my md files and custom components. Everything worked. The old project probably had some broken config.

Flagrare avatar Aug 27 '21 17:08 Flagrare

I faced that strange error message and had 500 files to check to find that tag I couldn't use. I used the following in config.js to find all tags that existed:

const tags = []

module.exports = {
	bundler: '@vuepress/webpack',
	bundlerConfig: {
		vue: {
			compilerOptions: {
				isCustomElement: tag => {
					if(!tags.includes(tag)){
						tags.push(tag)
						tags.sort()
						console.log(tags)
					}
					return false
				}
			}
		}
	},
	// ...
}

And then looked through the last array logged on the screen, and managed to find I used a custom component at one place that I had deleted.

PeppeL-G avatar Aug 29 '21 15:08 PeppeL-G