jasonmit / ember-cli-moment-shim

ember-cli shim for momentjs
MIT License
33 stars 59 forks source link

Can't build for production since moment v2.25.1 released #183

Closed elatonsev closed 4 years ago

elatonsev commented 4 years ago

Fixing moment version on 2.24.0 helps, but it is still an issue.

"resolutions": {
    "ember-cli-moment-shim/moment": "2.24.0"
}

https://github.com/adopted-ember-addons/ember-pikaday/issues/343#issuecomment-623244117

arenoir commented 4 years ago

I am also unable to build my application. Strangely it builds in development mode but not in test mode on circleci.



Merge error: conflicting capitalizations:

moment/locale/en-SG.js in /tmp/broccoli-80w9hTe17c2EFT/out-187-broccoli_persistent_filter_mapper

moment/locale/en-sg.js in /tmp/broccoli-80w9hTe17c2EFT/out-187-broccoli_persistent_filter_mapper

Remove one of the files and re-add it with matching capitalization.
 ``
jrjohnson commented 4 years ago

I've been digging into this. It appears that moment.min.js in Moment 2.25.0+ is valid, but when it is used in an ember app it produces invalid JS which terser cannot process. I haven't figured out why yet. One possible option is for this addon to bundle the non-minified moment.js and let them consuming app handle minification as it does for other assets.

Terser Issue: https://github.com/terser/terser/issues/684 Ember Moment Issue: https://github.com/stefanpenner/ember-moment/issues/328

jasonmit commented 4 years ago

Versioned in 3.8.0

bmaehr commented 4 years ago

Fixing moment version on 2.24.0 helps, but it is still an issue.

"resolutions": {
    "ember-cli-moment-shim/moment": "2.24.0"
}

didn't fix it for me.

Neither 3.8.0 did it.

  - broccoliBuilderErrorStack: SyntaxError: Unexpected token: eof (undefined)
    at ee (/mnt/DATA/jenkins/workspace/pubx_Build_QA/ui/ui/src/main/emberapp/node_modules/terser/dist/bundle.min.js:1:19541)
ember-cli-moment-shim@3.8.0, ember-cli-moment-shim@^3.6.0:
  version "3.8.0"
  resolved "https://registry.yarnpkg.com/ember-cli-moment-shim/-/ember-cli-moment-shim-3.8.0.tgz#dc61bbac9dce4963394e60dd42726d4ba38e2bc1"
  integrity sha512-dN5ImjrjZevEqB7xhwFXaPWwxdKGSFiR1kqy9gDVB+A5EGnhCL1uveKugcyJE/MICVhXUAHBUu6G2LFWEPF2YA==
  dependencies:
    broccoli-funnel "^2.0.0"
    broccoli-merge-trees "^2.0.0"
    broccoli-source "^1.1.0"
    broccoli-stew "^1.5.0"
    chalk "^1.1.3"
    ember-cli-babel "^7.1.2"
    ember-cli-import-polyfill "^0.2.0"
    ember-get-config ""
    lodash.defaults "^4.2.0"
    moment "^2.19.3"
    moment-timezone "^0.5.13"

Or

"resolutions": {
     "moment": "2.24.0"
}
bmaehr commented 4 years ago

Combining all together worked:

  "resolutions": {
    "ember-cli-moment-shim": "3.8.0",
    "moment": "2.24.0",
    "ember-cli-moment-shim/moment": "2.24.0"
  }
zardaloop commented 4 years ago

@bmaehr thanks for sharing this solution, it seems this is the only way for the time being to resolve this issue.

jrjohnson commented 4 years ago

It may be that you have other packages relying on the wrong version of ember-cli-moment-shim try running npm ls ember-cli-moment-shim or yarn list --pattern moment and see what shows up.

Or it may be that this fix didn't actually fix the issue, do you have an app or branch I can take a look at to test?

zardaloop commented 4 years ago

@jrjohnson Hi Johnathan. Thanks for your comment. It is actually an internal project we have. The problem is, we have many small internal ember addons, some of those addons have the ember-cli-moment-shim fixed to 3.7.1. So they don't have any hat "^". However it seems there are some other third party packages that we are using which are also using ember-cli-moment-shim and those have hat. Therefore since last week you released version 3.8.0 we are having that issue. If I use resolutions, it fixes the issue for the project (not a real fix but I can still serve it). But if I use npm link to link the other add-on to my main projects to work on those add-ons I still get the same error.

jrjohnson commented 4 years ago

That makes sense without the ^ you won't get this fix and will still need to pin the moment version. In fact with Ember addons you sometimes can't actually determine what version you will get. Highly recommend ember-cli-dependency-lint as a way to track down these conflicts and add tests to ensure they don't pop up again.

zardaloop commented 4 years ago

@jrjohnson Many thanks Johnathan, I did not know about that package. I will install it and will it a go.