-
Notifications
You must be signed in to change notification settings - Fork 392
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(lwc-compiler): add baseDir support #375
Conversation
Used by playground to compile sub components. Need baseDir to indicate position of root component within files object.
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.
two small change:
- missing build:umd script, i believe it was removed from lwc-compiler/packages.json
- please add a test to cover baseDir functionality as well as the negative scenario when importer is undefined and baseDir is not specified.
@@ -1,5 +1,9 @@ | |||
import { isBoolean, isString, isUndefined } from "../utils"; | |||
|
|||
const DEFAULT_OPTIONS = { | |||
baseDir: "", |
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.
it would be great to have a small comment explaining the need for the baseDir
return; | ||
} | ||
|
||
const relPath = importee ? path.dirname(importee) : ""; | ||
let absPath = path.join(relPath, id); | ||
const relPath = importer ? path.dirname(importer) : options.baseDir || ""; |
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.
do we need a more specific error message when importer is undefined and baseDir is not specified or should the line 65 take care of it?
Benchmark resultsBase commit: lwc-engine-benchmark
|
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.
One small change for the jest test
...COMPILER_CONFIG_BASEDIR | ||
}; | ||
delete config.baseDir; | ||
try { |
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.
it is better to use expect().rejects to ensure rejection is triggered
await expect(compile(config)).rejects.toMatchObject({
message: Could not resolve 'foo' (as foo.js) from compiler entry point
});
});
if (importer) { | ||
throw new Error(`Could not resolve '${importee}' (as ${absPath}) from '${importer}'`); | ||
} | ||
throw new Error(`Could not resolve '${importee}' (as ${absPath}) from compiler entry point`); |
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.
thanks for the explicit error!
Benchmark resultsBase commit: |
Benchmark resultsBase commit: lwc-engine-benchmark
|
Benchmark resultsBase commit: lwc-engine-benchmark
|
Used by playground to compile sub components. Need baseDir to
indicate position of root component within files object.
Details
Does this PR introduce a breaking change?
If yes, please describe the impact and migration path for existing applications:
Please check if your PR fulfills the following requirements: