-
Notifications
You must be signed in to change notification settings - Fork 514
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
Extract CLI into separate module #249
Conversation
@@ -8,7 +8,8 @@ module.exports = { | |||
entry: "./index.js", | |||
output: { | |||
path: distPath, | |||
filename: "cli.js" | |||
filename: "ssr.js", | |||
libraryTarget: "commonjs2" |
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.
Why/what is this?
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.
Otherwise the ssr module can"t be imported by our cli module. Webpack doesn"t create importable bundles by default.
(don"t squash this commit, it temporarily names the cli module "new-cli", so that git"s file tracking algorithm doesn"t get confused)
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 looks gorgeous!
Can you figure out why yarn test
is broken first?
▶ yarn test
yarn run v1.19.1
$ yarn prettier-check && yarn workspace ssr test && yarn workspace client test
$ prettier --check **/*.{js,json,scss,html}
Checking formatting...
All matched files use Prettier code style!
$ jest
FAIL ./syntax-highlighter.test.js
● Test suite failed to run
/Users/peterbe/dev/MOZILLA/MDN/stumptown-renderer/ssr/syntax-highlighter.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import cheerio from "cheerio";
^^^^^^
SyntaxError: Cannot use import statement outside a module
> 1 | const { fixSyntaxHighlighting } = require("./syntax-highlighter");
| ^
2 |
3 | test("adds 1 + 2 to equal 3", () => {
4 | expect(sum(1, 2)).toBe(3);
at ScriptTransformer._transformAndBuildScript (../node_modules/@jest/transform/build/ScriptTransformer.js:537:17)
at ScriptTransformer.transform (../node_modules/@jest/transform/build/ScriptTransformer.js:579:25)
at Object.require (syntax-highlighter.test.js:1:35)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 1.396s
Ran all test suites.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed.
Exit code: 1
Command: /usr/local/Cellar/node/12.12.0/bin/node
Arguments: /usr/local/Cellar/yarn/1.19.1/libexec/lib/cli.js test
Directory: /Users/peterbe/dev/MOZILLA/MDN/stumptown-renderer/ssr
Output:
info Visit https://yarnpkg.com/en/docs/cli/workspace for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
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.
Actually, we were never testing yarn test
before. We"ll have to fix that some other day.
Oh yeah I was wondering whether we might want to rename |
?? The end-to-end tests do very different things. It basically tests from bash whereas |
Oh right, forgot that we"re running the workspace tests in there already. I guess I was wondering whether we want that command to also run the end-to-end test, feels natural to me to have the root |
So I tried to keep it minimal-ish for now, the changes basically come down:
I created two commits as it seemed that git otherwise thinks that the new
cli
-module"sindex.js
is thessr
module"s (as it was previously namedcli
), hence no file history tracking. Unfortunately that didn"t seem to have done the trick :/