-
Notifications
You must be signed in to change notification settings - Fork 199
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
Added a polyserve option doNotCompile and speed up WCT tests #168
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,14 @@ export const args: ArgDescriptor[] = [ | |
type: String, | ||
defaultValue: 'auto', | ||
}, | ||
{ | ||
name: 'do-not-compile', | ||
description: 'Disables compilation for file(s) matching given pattern. ' + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we clarify what we mean by compilation? As currently written, it bypasses ES5 compilation, but also name-to-path transformation and AMD transformation. compile-middleware is already probably too aggressive in this regard, since the |
||
'Value given may contain glob-style wildcards such as *, **, and ?. ' + | ||
'Use multiple --do-not-compile flag for multiple patterns.', | ||
type: String, | ||
multiple: true, | ||
}, | ||
{ | ||
name: 'module-resolution', | ||
description: 'Algorithm to use for resolving module specifiers in import ' + | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ import {parse as parseContentType} from 'content-type'; | |
import {Request, RequestHandler, Response} from 'express'; | ||
import * as fs from 'fs'; | ||
import * as LRU from 'lru-cache'; | ||
import * as minimatch from 'minimatch'; | ||
import * as path from 'path'; | ||
import {htmlTransform, jsTransform} from 'polymer-build'; | ||
|
||
|
@@ -60,7 +61,8 @@ export function babelCompile( | |
rootDir: string, | ||
packageName: string, | ||
componentUrl: string, | ||
componentDir: string): RequestHandler { | ||
componentDir: string, | ||
doNotCompile: string[] = []): RequestHandler { | ||
return transformResponse({ | ||
|
||
shouldTransform(request: Request, response: Response) { | ||
|
@@ -69,6 +71,11 @@ export function babelCompile( | |
if (isPolyfill.test(request.url)) { | ||
return false; | ||
} | ||
if (doNotCompile.length > 0 && | ||
!!doNotCompile.find((p) => minimatch(request.url, p))) { | ||
console.log('SKIPPY MA-DOO-DAH',request.url); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lol |
||
return false; | ||
} | ||
if (!compileMimeTypes.includes(getContentType(response))) { | ||
return false; | ||
} | ||
|
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.
Now we have
--compile
and--do-not-compile
, which might be slightly confusing. I guess we should just document the interaction between the two, especially that this takes precedence over--compile=always
?(I was also thinking we could update the
--compile
flag to take glob patterns (and minimatch already supports the!
operator), but then you still have theauto
vsalways
difference that needs to be represented somehow. Not sure if this idea makes sense.)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.
Possible alternate names:
--pass-thru
--do-not-modify
--serve-as-is
--as-is
--no-transform
--no-rewrite
--immutable
--static
--constant
--invariant
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.
But do we want to disable all the transforms, or is this just about ES5 compilation?