Skip to content
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

vite-plugin-cdn2: vue Maximum call stack size exceeded #47

Open
Bisstocuz opened this issue Apr 10, 2024 · 4 comments
Open

vite-plugin-cdn2: vue Maximum call stack size exceeded #47

Bisstocuz opened this issue Apr 10, 2024 · 4 comments

Comments

@Bisstocuz
Copy link

cdn({
	modules: [{ name: "vue", relativeModule: "vue.global.prod.min.js" }, "vue-router", "vue-demi", "pinia", "axios" ],
	resolve: defineResolve({
		name: "resolve:custom",
		setup({ extra }) {
			const baseURL = "https://cdn.staticfile.net/";
			const { version, name, relativeModule } = extra;
			const url = new URL(`${name}/${version}/${relativeModule}`, baseURL);
			return {
				url: url.href,
				injectTo: "head-prepend",
				attrs: {
					crossOrigin: 'anonymous'
				},
			};
		},
	})
})

And there is no vue in output:

<script crossOrigin="anonymous" src="https://cdn.staticfile.net/vue-router/4.2.0/dist/vue-router.global.js"></script>
<script crossOrigin="anonymous" src="https://cdn.staticfile.net/vue-demi/0.14.6/lib/index.iife.js"></script>
<script crossOrigin="anonymous" src="https://cdn.staticfile.net/pinia/2.1.7/dist/pinia.iife.js"></script>
<script crossOrigin="anonymous" src="https://cdn.staticfile.net/axios/1.5.0/dist/axios.min.js"></script>
@nonzzz
Copy link
Owner

nonzzz commented Apr 10, 2024

relativeModule means the package root path.Usually contain package.json. AFAIK vue bundle asserts contain dist directory. I might think u can try "./dist/xxx"? Another way to change it you can do your logic in plugin system.

@Bisstocuz
Copy link
Author

Bisstocuz commented Apr 11, 2024

relativeModule means the package root path.Usually contain package.json. AFAIK vue bundle asserts contain dist directory. I might think u can try "./dist/xxx"? Another way to change it you can do your logic in plugin system.

My code was modeled after this docs

The path of assets doesn't always include dist, for example, check this: https://cdnjs.com/libraries/vue

Could you please provide a simple example about how to change this behavior?

@nonzzz
Copy link
Owner

nonzzz commented Apr 11, 2024

relativeModule is use for code block. Notice you relativeModule is vue.global.prod.min.js isn't be pass.

You can get package name in setup. so you just using the follow logic.

if (name === 'vue') {

// do your logic.

return 

}

... etc

@nonzzz
Copy link
Owner

nonzzz commented Apr 11, 2024

I've been busy recently. Some of logic and document isn't friendly. I create a new branch to redesign some of logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants