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

Support for CommonJS? #1

Closed
niksy opened this issue Apr 18, 2017 · 3 comments · Fixed by #3
Closed

Support for CommonJS? #1

niksy opened this issue Apr 18, 2017 · 3 comments · Fixed by #3
Labels

Comments

@niksy
Copy link

niksy commented Apr 18, 2017

Currently, transform expects that final code uses ES modules, but maybe there could be option to switch to CommonJS require?

Code for require would look something like this:

const declar = t.variableDeclaration('var', [t.variableDeclarator(t.identifier(OBJECT_ASSIGN), t.callExpression(t.identifier('require'), [t.stringLiteral(OBJECT_ASSIGN)]))]);

What do you think? I could create PR for this if you’re interested.

@newoga
Copy link
Owner

newoga commented May 21, 2017

@niksy I apologize for the late response, I am just seeing this now.

I'm not against the change you are suggesting, however I am curious about what you are using this project for. The reason why I'm asking is because I was just recently planning on formally deprecating this project on npm as a lot has changed since this project was created and the primary motivation that lead to me creating this project was an bug in Chrome that was fixed.

Thanks for your interest and contributing in open source 😄

@niksy
Copy link
Author

niksy commented May 22, 2017

@newoga it’s for the projects which don’t use ES imports and can benefit from not including same code in every file. Granted, there will be less and less projects over time like that, but it can be useful when publishing transpiled code for package and smaller output.

I can create PR if you’re interested.

@newoga
Copy link
Owner

newoga commented Aug 2, 2017

@niksy Hey, sorry again for the late response. My email still gets overwhelmed from github emails relating to the material-ui project. If this change still has value for you, I'd be glad to accept a PR for it and release a new version.

jaydenseric added a commit to jaydenseric/babel-plugin-transform-replace-object-assign that referenced this issue Mar 19, 2018
Fixes newoga#1.

Also improves the fixuture expected outputs.
@newoga newoga added bug and removed enhancement labels Mar 19, 2018
@newoga newoga closed this as completed in #3 Mar 19, 2018
newoga pushed a commit that referenced this issue Mar 19, 2018
* Updates for Babel v7 compatability.

- Updated dependencies.
- New plugin implementation for Babel v7.
- Use @babel/helper-module-imports so the output is either ESM or CJS depending if sourceType is module or script, fixing #1.
- Added @babel/core peer dependency, as Babel does for official plugins.
- Disabled and ignored package-lock.json.
- Replaced lodash.assign in readme examples with object-assign to demo defaults.
- New way to register Babel for Mocha tests.

Huge thanks to @jaydenseric for implementing this!
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.

2 participants