-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
ESBuild not possible when using flag-icons #1142
Comments
Would you be able to provide a minimal reproducible repository? I suspect esbuild is trying to place 1x1 and 4x3 resolutions in the same output folder. |
I'm afraid I can't provide a repository, but I can refer to some of the features of the build: We are using: The Angular build executor is using: The ts.config.base.json is using: And you are correct: ESBuild seems to be putting both resolutions in the same folder, but they have identical names. I found a workaround which was to put: script in the index.html, but this is sub-optimal IMO as it means we would need to update the package in both package.json and index.html.Any help would be greatly appreciated! |
Hi, is this something that is fixable or should we look towards alternative options? |
Any solution for this issue? |
I have still not found a solution and therefore we cannot use esbuild in our project yet. |
Same problem here. I'm using version 6.14.0. |
As previous posts indicated, the issue is this:
Both file will be copied in the same directory with the same name.
This way, image names won't collide anymore. |
Having the same issue here, we tried to upgrade our project with the Angular latest release (v17) , but the application bundle generation fails with the new ESBuild I don't have a minimal reproducible repository, but on our side we have this configuration: package.json
Including these styles in the build process means that they will be compiled and bundled with the rest of the application's assets when we build the Angular project. If you need, some further documentation is provided here As a upgrade-blocking issue, if you could fix it that'd be great! |
You can fix the issue by adding outputHashing to the development configuration: "configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"outputHashing": "all"
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true,
"outputHashing": "media"
}
} |
Well, know I know what is the purpose of this outputHashing stuff. Thanks a lot for the tip, works like a charm |
This hasn't worked for us, we still get the same errors. This is now blocking us from updating to Angular v.17. |
Ensure that you apply it to the correct configuration. |
I have copied the above and still get the same issues... |
can you maybe post your whole angular.json in here (not doubting you, just trying to find out the difference with mine to help you)? |
"options": { |
You need to add outputHashing to your development configuration: "options": {
"baseHref": "/",
"outputPath": "dist/apps/XXXX/browser/browser",
"index": "apps/XXXX/src/index.html",
"main": "apps/XXXX/src/main.ts",
"tsConfig": "apps/XXXX/tsconfig.app.json",
"polyfills": "apps/XXXX/src/polyfills.ts",
"assets": [
"apps/XXXX/src/assets/icon",
"apps/XXXX/src/favicon.ico",
"apps/XXXX/src/manifest.webmanifest",
{
"input": "apps/XXXX/src/assets/config/development",
"glob": ".json",
"output": "assets/config"
},
{
"input": "libs/shared/ui/assets",
"glob": "**/",
"output": "assets"
}
],
"styles": [
"node_modules/@angular/material/prebuilt-themes/deeppurple-amber.css",
"node_modules/katex/dist/katex.css",
"node_modules/flag-icons/css/flag-icons.min.css",
"node_modules/intro.js/introjs.css",
"apps/XXXX/src/styles.scss"
],
"stylePreprocessorOptions": {
"includePaths": ["apps/XXXX/src/styles"]
},
"scripts": ["node_modules/webfontloader/webfontloader.js", "node_modules/intro.js/intro.js"],
"allowedCommonJsDependencies": ["dayjs", "katex", "extract-math"],
"inlineStyleLanguage": "scss",
"customWebpackConfig": {
"path": "./webpack.config.js"
}
},
"configurations": {
"defaultConfiguration": "development",
"development": {
"outputHashing": "media",
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
},
"production": {
"serviceWorker": true,
"ngswConfigPath": "apps/XXXX/ngsw-config.json",
"assets": [
"apps/XXXX/src/assets/icon",
"apps/XXXX/src/favicon.ico",
"apps/XXXX/src/manifest.webmanifest",
{
"input": "apps/XXXX/src/assets/config/production",
"glob": ".json",
"output": "assets/config"
},
{
"input": "libs/shared/ui/assets",
"glob": "**/",
"output": "assets"
}
],
"sourceMap": {
"scripts": true
},
"optimization": true,
"outputHashing": "all",
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [
{
"replace": "apps/XXXX/src/environments/environment.ts",
"with": "apps/XXXX/src/environments/environment.prod.ts"
}
]
}
} |
Ah sorry I'd just removed that while reverting my changes. It still doesn't work so I will need to continue using webpack browser |
When I changed the build to application, I had to change this line:
to
but I see that it's not the case for you. |
Yes I already tried that as well, no luck... |
Is this something this library is planning on supporting? @lipis |
@joewIST What exactly should we do? |
Renaming the files as I suggested might be a viable solution. |
Renaming the files? Haven't really followed closely the conversation.. all we offer in this library is bunch of files and the css for it.. there is no |
The issue is that when using esbuilder, all files end up in the same directory and as files in 1x1 have the same names as the ones in 4x3, it creates an override issue. There is a possibility to configure esbuilder to hash the names but it seems that it does not work for everyone. Therefore, a solution would be to rename files in 1x1 with the suffix "-1x1" and same for "4x3". |
Yes the duplicate file issue is basically blocking us from upgrading from esbuild, and therefore from fully taking advantage of Angular v.17. I have tried outputHashing but it's not working... |
While enabling More about esbuild asset hashing: Following this, there is no reason that the duplicate file issue of this library remains with the hashing enabled. You should recheck the esbuild configuration in your project. That being said, the main issue is that esbuild in general conflicts with the architecture of this library. Its not an Angular issue. |
Keep in mind the renaming for the files will be a breaking change as well. If you'd like, I can provide a batch script in the project root that appends the -1x1 and -4x3 to the respective flags (and maybe one to perhaps undo it?), and then you should be able to invoke that from your package.json via |
To be honest, the outputHash works with me, so it does not matter. However, people are not supposed to use images directly, are they? So if you adapt the scss to the new image names, why would it be a breaking change? |
OK I managed to get outputHashing to work, but I needed to put it in the "options" part of the build configuration, not in the "configurations" -> "development" section. Not sure why but that works. We are still blocked from fully integrating esbuild due to our reliance on sentry (which needs a webpack plugin; no support for esbuild plugins yet without custom implementation), but at least I know I can do a workaround for this library. Thanks @ssougnez ! |
@ssougnez not many people are using the css at all but directly the images (including me in some projects).. the css is an add on.. the main product is the flag icons as the name suggests :) |
Yeah sorry, I'm still on the old one which was flags-icon-css or something wasn't it? Ok then, I understand the breaking change :-) Now, it seems that the one who had an issue with outputHash fixed it so maybe the issue is no longer relevant. |
At the very least, I'll push a change to the README.md referencing this issue for ESBuild usage. If there's any desire for a script to rename the flags on the fly, I can add that on-demand. |
I'm down on updating the Readme and adding a script for those users if needed... |
I personally dont like hashing images if they're not changing. Because that would mean that browsers will need to redownload them everytime a new build is released. Is it possible for us to just rename the file or add the files so that this isn't an issue with bundlers? |
As previously mentioned, the reason I'm hesitant to push a change like that is that there are several packages/libraries/applications that link directly to the flags inside the repo (which isn't really encouraged, but it is fairly common), so this can break resolution if we suddenly change with no advance notice. I guess ultimately, we should aim to:
That would be the path of least resistance. Naturally, there will still be people that won't read this and we would run into issues, but that's unavoidable. I've noticed from working on JavaScript projects that sometimes when you pull packages they include notices or comments, like depcrecation warnings for renamed packages, etc. I wonder if we can make use of that to provide additional notice regarding renaming the flags if we end up choosing to do so. Thoughts? @lipis Also updated my public facing email, feel free to bring this over to email as well: [email protected] |
To be honest, that's what major versions are for... No one should upgrade a library to a new major version without paying attention to the breaking changes. If you include a clear explanation in the readme about it, it should be enough. |
I agree with @ssougnez . The change should just be a move to new file names and make it a new major version. |
@NotTsunami Let's agree on the final naming and we can do it eventually.. yes no need to announce anything.. new major version with breaking changes.. who ever is using the website for showing the flags I don't care to be honest.. it's not fair anyway :) |
i've just been beaten up by this after switching to esbuild |
Still can't get it to work with |
I made a fork as a temporary solution for people like me who can't wait: Beware tho that this is no drop in replacement as imports need to change |
The outputHashing worked like a charm with flag-icons v: 7.2.1 and angular v: 17.3.5... |
We have an Angular application inside an Nx monorepo. I'd like to start using ESBuild as a builder for improved build speeds, but we are currently blocked by flag-icons. The following errors occur and the build fails:
Two output files share the same path but have different contents: xx.svg
Is there anything we can do to avoid/fix this?
Much appreciated!
The text was updated successfully, but these errors were encountered: