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

About import.meta.url #326

Closed
NNBishoper opened this issue May 13, 2022 · 6 comments
Closed

About import.meta.url #326

NNBishoper opened this issue May 13, 2022 · 6 comments

Comments

@NNBishoper
Copy link

Hi.

I use zip.js for my web project in browser.

Because of this, the bundle contains the env local path like "file:///*/@zip.js+zip.js@2.4.10/node_modules/@zip.js/zip.js/lib/zip-fs.js", which may cause the security issue.

Now my solution is to replace import.meta.url with '' before build, which is so trick.

Is there any way to solve this from your point of view. I think web project in browser is no need for this.

Thank you.

@gildas-lormeau
Copy link
Owner

Isn't this a bug in the bundling tool you're using?

@NNBishoper
Copy link
Author

Isn't this a bug in the bundling tool you're using?

I don't think so. The project was built with Webpack in the building server, so import.meta.url would get the local env path, which is reasonable, like this:

// my usage

import { ZipReader, HttpReader, TextWriter, BlobWriter } from '@zip.js/zip.js';

// ...
// vendors.*.js

// ...

try{un="file:///*/@zip.js+zip.js@2.4.10/node_modules/@zip.js/zip.js/lib/zip-fs.js"}catch(cn){}Y({baseURL:un})

// ...

I just want to know is there any way to remove this by config, which I think is no need for web project in browser.

try {
	baseURL = import.meta.url;
} catch (error) {
	// ignored
}

If there is no good configurable way to solve this, I may keep the trick solution.

@gildas-lormeau
Copy link
Owner

gildas-lormeau commented May 15, 2022

It's a bug in webpack, here's the links to the corresponding issues webpack/webpack.js.org#6087, webpack/webpack#14445. It looks like it's adjustable though.

@gildas-lormeau
Copy link
Owner

gildas-lormeau commented May 16, 2022

@NNBishoper Did you try to set importMeta to false in your configuration file?

@NNBishoper
Copy link
Author

@NNBishoper Did you try to set importMeta to false in your configuration file?

LGTM. I will try it later. Thank you so much.

@gildas-lormeau
Copy link
Owner

You're welcome. I'm closing and moving the issue in the Discussions tab to keep it visible.

Repository owner locked and limited conversation to collaborators May 17, 2022
@gildas-lormeau gildas-lormeau converted this issue into discussion #328 May 17, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants