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

Sourcemaps + fingerprinting regression with ember-cli-terser 4.0.2? #275

Open
jviney opened this issue May 13, 2021 · 9 comments · May be fixed by #298
Open

Sourcemaps + fingerprinting regression with ember-cli-terser 4.0.2? #275

jviney opened this issue May 13, 2021 · 9 comments · May be fixed by #298
Labels

Comments

@jviney
Copy link

jviney commented May 13, 2021

The combination of ember-cli-terser 4.0.2, sourcemaps, and asset fingerprinting with the prepend option seems broken. It works with 4.0.1.

The generated sourcemap just has a single file in its "arrays" property. Eg: { "sources":["assets/app-24b6516628ce0829b2e18e768cd8ce2b.js"] , instead of the full list of source files you'd expect.

It appears to work correctly if the fingerprint.prepend option is removed.

May be caused by one of these:

97cef3c
8279c89

Is this a known problem? I've downgraded to 4.0.1 for now.

@apellerano-pw
Copy link

apellerano-pw commented Jun 18, 2021

I also have an issue with sourcemap fingerprinting in 4.0.2.

The behavior change is demonstrated below. 4.0.2 is giving sourcemaps a unique fingerprint in assetMap.json, but the actual sourcemap file outputted shares its fingerprint with the js file. 4.0.1 does not do this.

Using 4.0.2

// assetMap.json
"assets/test-support.js": "assets/test-support-dbb5b19fdf03c2859ae16e7a1dc9f707.js",
"assets/test-support.map": "assets/test-support-a232a08ab47844d681757e283aac30fb.map",
"assets/vendor.js": "assets/vendor-a63514bff922c4c7f9211ecf9cf9a95c.js",
"assets/vendor.map": "assets/vendor-4548cf25b0650519a3bf0fcebb824d59.map",
% ls dist/assets/ | grep "\.map\|\.js"
test-support-dbb5b19fdf03c2859ae16e7a1dc9f707.js
test-support-dbb5b19fdf03c2859ae16e7a1dc9f707.map
vendor-a63514bff922c4c7f9211ecf9cf9a95c.js
vendor-a63514bff922c4c7f9211ecf9cf9a95c.map

Using 4.0.1

// assetMap.json
"assets/test-support.js": "assets/test-support-89a301f350d8c442d70b96cac2dc78ea.js",
"assets/test-support.map": "assets/test-support-88005702a86610103bf026f97bdad64c.map",
"assets/vendor.js": "assets/vendor-bf70bec9c3a1a3e083ff253e401d322a.js",
"assets/vendor.map": "assets/vendor-db69401ed5c970a866ea1dc33e0fa8b5.map",
% ls dist/assets/ | grep "\.map\|\.js"
test-support-88005702a86610103bf026f97bdad64c.map
test-support-89a301f350d8c442d70b96cac2dc78ea.js
vendor-bf70bec9c3a1a3e083ff253e401d322a.js
vendor-db69401ed5c970a866ea1dc33e0fa8b5.map

And here is my relevant configs from ember-cli-build.js

{
  fingerprint: {
    enabled: true,
    prepend: '[our cdn]',
    generateAssetMap: true,
    extensions: [
      'js', 'css', 'png', 'jpg', 'gif', 'map', // defaults
      'ico', 'svg', 'woff', 'woff2', 'ogg' // added by us
    ],
    exclude: [
      'assets/inline_svg/**/*',
      'assets/dynamic/*'
    ]
  },
  sourcemaps: {
    enabled: true,
  },
  'ember-cli-terser': {
    enabled: true,
    terser: {
      compress: false,
      mangle: true
    }
  }
}

@enspandi
Copy link

We're also seeing a few bugs in 4.0.1 and 4.0.2 and are reverting back to 3.0.0 for that reason. Either the prepended path was missing or it was concatenated incorrectly.

@NullVoxPopuli
Copy link

ESBuild had the same issue here: NullVoxPopuli#61
and I'm testing out moving broccoli-asset-rev to addon.before right now.

@apellerano-pw apellerano-pw linked a pull request Dec 17, 2021 that will close this issue
@rreckonerr
Copy link

rreckonerr commented Dec 27, 2021

Seeing the same issue here on v4.0.2. Downgrading to v4.0.1 works for me!


Sourcemaps referenced as to a relative path //# sourceMappingURL=app-872148ced72309772aa624ced3dfb68b.map instead of absolute //# sourceMappingURL=https://s3-eu-central-1.amazonaws.com/blabla/assets/app-872148ced72309772aa624ced3dfb68b.map.

Seems like wrong hash is being applied to .map files.

Console output ember build -prod

[TerserWriter][WARN] (broccoli-terser-sourcemap) "https://s3-eu-central-1.amazonaws.com/blabla/assets/app-a7d016737320d4b33763a690926b622f.map" referenced in "assets/app-872148ced72309772aa624ced3dfb68b.js" could not be found
[WARN] (broccoli-terser-sourcemap) "https://s3-eu-central-1.amazonaws.com/blabla/assets/vendor-859e1305b1dc366a97b803eec97b4df5.map" referenced in "assets/vendor-b3eeea38d69cb5b99f35ff8805ab60a3.js" could not be found

Configuration

    fingerprint: {
      enabled: true,
      extensions: [
        "pdf",
        "js",
        "css",
        "png",
        "jpg",
        "gif",
        "map",
        "otf",
        "eot",
        "svg",
        "ttf",
        "woff",
        "woff2",
      ],
      prepend: "https://s3-eu-central-1.amazonaws.com/blabla/",
    },

    sourcemaps: {
      enabled: true,
      extensions: ["js"],
    },

Dist folder contents

  • app-872148ced72309772aa624ced3dfb68b.js
  • app-872148ced72309772aa624ced3dfb68b.map
  • vendor-4d134e6c58b511425ff083b735069361.css
  • vendor-b3eeea38d69cb5b99f35ff8805ab60a3.js
  • vendor-b3eeea38d69cb5b99f35ff8805ab60a3.map

@bertdeblock bertdeblock added the bug label Feb 8, 2023
@runspired
Copy link

Using prepend results in Unexpected token punc «:», expected punc «,» even with sourcemaps disabled, it also results in lots of warnings like this:

[TerserWriter][WARN] (broccoli-terser-sourcemap) "<<CDN URL>>/assets/leaflet/leaflet-4eaa81e6e27a89ed2410a7c39048a397.js.map" referenced in "assets/leaflet/leaflet-4eaa81e6e27a89ed2410a7c39048a397.js" could not be found

@ddoria921
Copy link

Any update on this issue or how to work around it in the meantime? I'm also running into the error

[WARN] (broccoli-terser-sourcemap) "https://my.cdn.com/assets/web-859e1305b1dc366a97b803eec97b4df5.map" referenced in "assets/web-b3eeea38d69cb5b99f35ff8805ab60a3.js" could not be found

@NullVoxPopuli
Copy link

Does the problem still exist if broccoli-terser-sourcemap is upgraded to 4.1.1 in your lockfile?

@ddoria921
Copy link

@NullVoxPopuli the warning still exists when running ember-cli-terser@4.0.2 & broccoli-terser-sourcemap@4.1.1

Downgrading to ember-cli-terser@4.0.1 while still keeping broccoli-terser-sourcemap@4.1.1 makes the warning go away. But I then run into the issue @apellerano-pw mentioned #275 (comment)

@linearza
Copy link

This came back to bite us a second time - painful!

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

Successfully merging a pull request may close this issue.

9 participants