-
Notifications
You must be signed in to change notification settings - Fork 301
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
Import of 'intl' package fails in production mode #1925
Comments
Thanks for the report! Hmm, there were some changes in the optimization of bindings in production mode in 2.3.24. It may happen that the In the meanwhile can you please try the following instead? This is the recommended way for importing only for side effects: importSideEffects "intl/locale-data/jsonp/de-DE.js" |
I've made a minimal example to reproduce: https://github.com/nilshelmig/fable-bug It seems that the bug only occurs when calling Fable from JavaScript. When I use |
Ah, ok, thanks! Then I'm pretty sure what's the problem now. When you use a import expression, even if you put it inside a function, Fable will move it to the top of the translated JS file (because you can only have imports at the file level in JS). Because of this, if you're calling Fable from JS, in production mode, tree shaking will take place and remove the To avoid this, this kind of polyfill imports should always way in the main file (the entry point) of your app. Another alternative is to add the polyfills directly to the entry option of your Webpack config: module.exports = {
entry: ["intl/locale-data/jsonp/de-DE.js", "./src/myApp.js"],
// ...
} |
I solved this issue by removing the polyfill. It seems that Intl is supported by our targeted browsers. But I can't find an API to use Intl, so I had to use let [<Global>] private Intl : obj = jsNative
let datepicker props children =
let props = JS.Object.assign (createObj [ "DateTimeFormat" ==> Intl?DateTimeFormat
"locale" ==> "de-DE"
"firstDayOfWeek" ==> 1 ], props |> wrapProps)
ReactElementType.create DatePicker props children Any idea to make this cleaner? |
Yes! You can take the Intl module from the old Fable.Import.Browser and contribute it as a package in the new Browser bindings :) |
Will do that :) |
Description
We use the
material-ui
(0.20.1) datepicker in some old applications. For internationalization we use the Intl namespace. Since we need support for Internet Explorer 11, we use a polyfill packageintl
.Since Fable 2.3.24 we get the following error when building with webpack in production mode.
Repro code
We use the component like this
Expected and actual results
Expected
No runtime exception.
Actual
Runtime exception on page load
Related information
The text was updated successfully, but these errors were encountered: