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

Incorrect export handling #420

Open
K0stka opened this issue Feb 3, 2024 · 0 comments
Open

Incorrect export handling #420

K0stka opened this issue Feb 3, 2024 · 0 comments

Comments

@K0stka
Copy link

K0stka commented Feb 3, 2024

Version (from my composer.json file): "matthiasmullie/minify": "^1.3"

In my project, I have multiple JS files, that each do their own thing. I then use this library to minify them at runtime and in order to have proper type-checking I need to use import/export statements. However, the problem is that this library treats them just as if they were just normal pieces of the code.

Example:
file a.js

function foo(bar) {
  ...
} 
export foo;

file b.js

import foo from "./a"
const foobaz = foo("baz");
export foobaz;

The ideal output of this would be (not minified for readability):

function foo(bar) {
  ...
}
const foobaz = foo("baz");
export { foo, foobaz };

I.e. omitting the import statement because it isn't necessary and moving + combining the export at the bottom of the bundle.

However, this library simply minifies the files and combines them.

Have I missed anything?

Edit:
Thinking about it, even just removing the import/export statements alltogether would probably solve the issue, because this way we don't have to worry about what path are we importing from ect. and browsers don't really care about this if you are smart about naming things.

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

1 participant