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

fix(custom-webpack): support exporting function in config written in TS #627

Merged
merged 5 commits into from
Nov 29, 2019

Conversation

a1russell
Copy link
Contributor

@a1russell a1russell commented Nov 20, 2019

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

I noticed that TypeScript support was recently added, so I tried it out. It didn't seem to work with my config, and I am pretty sure it's because I am exporting a function rather than an object. The code that was added to support TypeScript only seems to test for objects before my PR.

Also, apologies, I couldn't find any tests to modify to account for my fix. You'll have to point them out to me if they exist.

What is the new behavior?

Exported function works with TypeScript config files.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

I should also point out that I couldn't get module.exports syntax to work at all. I think that would require change to the tsconfig, e.g. esModuleInterop or something as described on the Webpack documentation. I didn't try to fix that, though.

Copy link
Owner

@just-jeb just-jeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that was indeed missing. @arturovt can you point out to the tests please?

Repository owner deleted a comment from allcontributors bot Nov 21, 2019
@just-jeb
Copy link
Owner

@all-contributors please add @a1russell for bug and code

@allcontributors
Copy link
Contributor

@just-jeb

I've put up a pull request to add @a1russell! 🎉

@arturovt
Copy link
Collaborator

@a1russell hey, that would be great if you'd used the original PR template, thanks!

can you point out to the tests please?

Go to packages/custom-webpack/examples/full-cycle-app. See the func-webpack.config.js file there. Change its extension to .ts and also the path in angular.json.

I should also point out that I couldn't get module.exports syntax to work at all.

Could you provide a working example?

@arturovt
Copy link
Collaborator

@a1russell change the commit name to

fix(custom-webpack): support exporting function in config written in TS

to follow the conventional commits notation.

@a1russell
Copy link
Contributor Author

@a1russell hey, that would be great if you'd used the original PR template, thanks!

Edited original description to add back template.

can you point out to the tests please?

Go to packages/custom-webpack/examples/full-cycle-app. See the func-webpack.config.js file there. Change its extension to .ts and also the path in angular.json.

Thanks. I'll give this a go.

I should also point out that I couldn't get module.exports syntax to work at all.

Could you provide a working example?

I was referring to the syntax mentioned in the comment above the code I edited. I honestly am not sure what a working example would look like for that.

Copy link
Collaborator

@arturovt arturovt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for changing PR description. LGTM. Just awaiting CI.

@arturovt
Copy link
Collaborator

arturovt commented Nov 21, 2019

Could you edit commit name here?

image

You should have the Edit button here, click it and change it to:

fix(custom-webpack): support exporting function in config written in TS

@a1russell a1russell changed the title Support custom Webpack function in TypeScript. fix(custom-webpack): support exporting function in config written in TS Nov 21, 2019
@just-jeb
Copy link
Owner

Need to update the documentation in order to reflect the changes.

@a1russell
Copy link
Contributor Author

What documentation would need to be updated, please?

@just-jeb
Copy link
Owner

I'd say this is the most appropriate place: https://github.com/just-jeb/angular-builders/tree/master/packages/custom-webpack#custom-webpack-config-function.
Just give an example with TypeScript at the end.

packages/custom-webpack/README.md Outdated Show resolved Hide resolved
packages/custom-webpack/README.md Outdated Show resolved Hide resolved


```typescript
import { CustomWebpackBrowserSchema } from '@angular-builders/custom-webpack/dist';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@just-jeb should this be used publicly?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arturovt I don't see any problem with that.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could expose it publicly, thus it won’t be imported from the dist folder?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, up until TS support there was no need in exporting anything but now it totally makes sense.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it is already exported, so we just need to set "types": "dist/index.d.ts" in package.json (I believe it should work event without it, it should be the default entry)

@just-jeb just-jeb merged commit 9ecde07 into just-jeb:master Nov 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants