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
🐛 Upgrading from 1.2.0 to 1.3.0 breaks moment.js #418
Comments
Unsure yet exactly why the default behavior has changed, but the following is a workaround: // change this
import * as moment from 'moment';
// to this
import moment from 'moment';
OR
// change this
console.log ( moment() );
// to this
console.log( moment.default() ); |
The addition of the following lines resulted in the "breaking change". Commenting them out in master restores previous functionality: Lines 50 to 58 in 0eb4487
Original: #298 For reference, moment's "main": "./moment.js",
"jsnext:main": "./src/moment.js", |
@brandon93s |
@Olian04 edit: Didn't understood you were talking about ts. Yeah var _moment = require("moment");
var _moment2 = _interopRequireDefault(_moment);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
@fathyb yea, parcel users Babel for js files. But it uses tsc for ts files. So I'm not really sure how referring to Babel is relevant. Or am I missing something? |
@brandon93s what exactly makes this a question? o_0 |
@Olian04 TypeScript sources are treated like any JavaScript files once they are processed. If you use |
@Olian04 - mostly a parcel team question to spawn discussion on how to handle this. The change that lead to this behavior is valid, and consumers can get past it with appropriate imports. However, it won't be compatible in many cases with existing code so we'll need to determine a path forward for handling it. |
ah. so parcel doesnt work with typescript imports? |
Any update on this one? |
This is also breaking my project. I need |
#530 has been created to fix this and has been tested with |
I'm also using typescript in my projects now. I have experienced the same error as yours, Typescript is upgraded to version {
"esModuleInterop": true
} I solved moment js problem. try this! 👍 |
I've tried to use two react date UI packages that require('moment') and are broken by the es6'fying of the returned moment object (if I understand the issue correctly) by Parcel/Babel What exactly is happening, and is there anything I can do now to stop that happening? Such as a .babelrc option? Not using typescript. Not realistic to have to create forks of packages that then use moment to work around this. |
Your expectation is incorrect. If it worked in previous versions of parcel then that was a 🐛. |
I'm using typescript and when i upgrade parcel from 1.2.0 to 1.3.1 (I've tried with 1.3.0 as well) the
moment.js
library starts complaining aboutmoment
not being a function.🎛 Configuration (.babelrc, package.json, cli command)
No tsconfig.json
🤔 Expected Behavior
I would expect a
moment
object to be printed to the console.😯 Current Behavior
With parcel
v1.2.0
themoment
object is printed just fine. But with parcelv1.3.0
orv1.3.1
it throws a TypeError.🔦 Context
Gist of all files used to recreate bug: https://gist.github.com/Olian04/ce4e23c11a17d60c9a39247a879e54c7
🌍 Your Environment
The text was updated successfully, but these errors were encountered: