-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
feat(middleware): added manual file type option #2846
feat(middleware): added manual file type option #2846
Conversation
Adds a manual file type so that users can instruct Karma which method to use when loading a file without an extension (such as Google font files)
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
I signed it! |
CLAs look good, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, this looks like a good idea. A couple of things
- could you update the docs please to include this
- lets also add a
script
type for script files - can you add some validation to the type in the pattern, such that it logs a warning on unknow types?
Another thing I was just thinking of is if it should be |
lib/middleware/karma.js
Outdated
scriptTags.push(util.format(LINK_TAG_CSS, filePath)) | ||
continue | ||
} | ||
|
||
if (fileExt === '.html') { | ||
if (fileExt === '.html' || fileType === 'html') { | ||
scriptTags.push(util.format(LINK_TAG_HTML, filePath)) | ||
continue | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On line 208, scriptType
should be fileType || SCRIPT_TYPE[fileExt] || 'text/javascript'
. I think that would let us strip the code out of #2834 and just merge its tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GitHub sadly wouldn't let me comment on the correct line.
lib/middleware/karma.js
Outdated
scriptTags.push(util.format(LINK_TAG_CSS, filePath)) | ||
continue | ||
} | ||
|
||
if (fileExt === '.html') { | ||
if (fileExt === '.html' || fileType === 'html') { | ||
scriptTags.push(util.format(LINK_TAG_HTML, filePath)) | ||
continue | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GitHub sadly wouldn't let me comment on the correct line.
Made some changes, let me know what you think.
|
lib/middleware/karma.js
Outdated
'html', | ||
'js', | ||
'dart', | ||
'esModule' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is total bikeshedding, but this could be more simply called module
. It removes the only camel-cased option, and makes the API more consistent with the browser: type: 'module'
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine I was just copying from the previous PR but I think 'module'
is better. Fixed now
docs/config/01-configuration-file.md
Outdated
@@ -425,7 +425,7 @@ httpsServerOptions: { | |||
|
|||
**CLI:** `--log-level debug` | |||
|
|||
**Possible values:** | |||
**Possible Values:** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull requests usually follow the mantra "one idea -> one PR". This correction should probably have been a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, sorry about that. Reverted now. Should I squash all my commits?
Thank you |
Adds a manual file type so that users can instruct Karma which method to use when loading a file without an extension (such as Google font files)
Example:
Fix for #2824
First time working karma so let me know if there are any changes I need to make.