-
Notifications
You must be signed in to change notification settings - Fork 220
[quilt] Build Quilt using sewing-kit-next #1538
Conversation
d3b5765
to
e25b8e7
Compare
8df6187
to
29c9333
Compare
5fbbc8f
to
9957891
Compare
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.
I've only looked at the i18n
files (on "behalf" of intl-globalization
) but see no cause for concern there. OK by me, for what that's worth. :)
c382968
to
3505c07
Compare
.eslintrc.js
Outdated
'plugin:@shopify/react', | ||
'plugin:@shopify/jest', | ||
'plugin:@shopify/prettier', | ||
'plugin:@sewing-kit/typescript', |
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.
Where do these configs live?
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.
Here, I believe.
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.
Found it, https://github.com/lemonmade/sewing-kit/tree/main/packages/eslint-plugin/src/config
Not related to quilt. It's interesting that there's a@sewing-kit/eslint-plugin
vs @sewing-kit/plugin-eslint
. One is a plugin for sewing-kit and one is an eslint plugin.
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.
Sorry, github is being wonky with this big PR. Comment thread didn't' refresh and the page is freezing.
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.
You should keep the Shopify ESLint plugins, I only added a custom ESLint plugin in sewing-kit to get rid of a few rules I hate, and show how it could be authored with TypeScript (unlike our actual plugin, that's all in JS)
@@ -23,6 +23,7 @@ | |||
"build": true, | |||
"**/*.js": true | |||
}, | |||
"typescript.tsserver.maxTsServerMemory": 8000, |
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.
Can you share some re-producible steps for the issues you had with VSCode, please? I can try to take a deeper look.
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.
Sure thing:
- Pull this branch down and open it in VS Code
- Get rid of the
typescript.tsserver.maxTsServerMemory
setting fix - Close all tabs in and close VS Code
- Open Quilt in VS Code
- Open
sewing-kit.config.ts
in the workspace root - On my editor at least, the builtin TS/JS plugin hangs and never stops initializing, as noted in the bottom toolbar. The plugin eventually restarts itself a couple times and then crashes, leaving a warning popup
In VS Code you can use the command >Open TS Server log
to see the plugin logs. For me, the logs just stop in the middle of loading a package around halfway through.
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.
I was able to repro this on first attempt. I tried a few hacks to see what would happen (eg. move the root tsconfig.json
to packages/tsconfig.json
). That seemed to help. I reverted my changes and cleaned out my git env and I'm not able to reproduce this anymore :/
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 might have something to do with my own local setup then 🤔 @lemonmade @TheMallen is this an issue for you guys as well?
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.
I'll try it out after our 1:1
config/sewing-kit/index.ts
Outdated
return createComposedProjectPlugin<Package>('Quilt.Package', [ | ||
javascript(), | ||
typescript(), | ||
react(), |
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.
We have some quilt packages that don't use any react (eg. address-consts
). Do they still need the react
plugin?
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.
Probably not, I can make that configurable via arguments instead 👍
createProjectTestPlugin, | ||
createProjectBuildPlugin, | ||
} from '@sewing-kit/plugins'; | ||
import {react} from '@sewing-kit/plugin-react'; |
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.
Something to keep in mind for the future. It would be nice to have some of these common plugins re-exported from @sewing-kit/plugins
so devs can do something like:
import {
// other stuff
react,
javascript,
typescript,
} from '@sewing-kit/plugins';
instead of
import {react} from '@sewing-kit/plugin-react';
import {javascript} from '@sewing-kit/plugin-javascript';
import {typescript} from '@sewing-kit/plugin-typescript';
@lemonmade do you foresee any issues with 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.
I agree the core plugins are annoying to remember what all the package names are
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 what composed plugins are for (e.g., https://github.com/lemonmade/quilt/blob/main/packages/sewing-kit-plugins/src/index.ts#L29), so I don't think it's needed.
config/sewing-kit/index.ts
Outdated
}; | ||
} | ||
|
||
export function quiltPackage({binaryOnly = true, jestEnv = 'jsdom'} = {}) { |
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.
What's this binaryOnly
flag for? It's defaulted to true and I don't see it being used anywhere else?
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.
I think I just copied that from Chris' Quilt config. Wasn't sure if we wanted .mjs
and .esnext
files in our builds. I can get rid of it and hardcode that to be true
instead for now.
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.
Let's leave them out for now. Adding support for .mjs
and .esnext
feels out of scope in validating sewing-kit-next in quilt.
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.
disagree, one of the major benefits of using sewing-kit-next is that it outputs files that are actually tree-shakeable.
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.
I stand corrected. @b-ryu, sorry for the confusion. We'll need this.
@@ -24,7 +24,7 @@ | |||
}, | |||
"homepage": "https://github.com/Shopify/quilt/blob/master/packages/address-consts/README.md", | |||
"files": [ | |||
"dist/*", | |||
"build/*", |
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.
Is there a reason why these are all changing to build
? Anyway we can keep it as dist
?
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.
Looking through the plugin code I don't believe it's a hard requirement, but I think it's the preferred default. I'll see if keeping it as dist
changes anything 👍
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.
Something to verify. Do to generated root level entry points respect the output folder in the tsconfig.
- Update the output folder in
packages/web-worker/tsconfig.json
todist
- Run a build
- Verify that all the root level entry points generated for the following include a
./dist
pkg.entry({root: './src/index'});
pkg.entry({name: 'babel', root: './src/babel-plugin'});
pkg.entry({name: 'webpack', root: './src/webpack-parts'});
pkg.entry({name: 'worker', root: './src/worker'});
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.
Did some digging. Apparently setting outDir
in tsconfig.json
only affects TS output. It seems that other outputs are hardcoded to go into the build
folder (the generated entrypoints point to the proper respective folder).
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 digging into this. I'm ok with standardizing on our tooling to use build
as the default output dir. We'll just need to make sure we update all our cases where we hard-coded dist
. @shopify/polyfills
comes to mind. It's hurt us in the past.
We'll probably want an escape hatch out of this in the future though, unless it's already possible today (cc/ @lemonmade)
@@ -3,8 +3,8 @@ | |||
"version": "2.0.1", | |||
"license": "MIT", | |||
"description": "Constants and types relating to `@shopify/address`", | |||
"main": "dist/src/index.js", | |||
"types": "dist/src/index.d.ts", | |||
"main": "index.js", |
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.
Is outputting an index.js
in the root a defaults from sewing-kit next? I personally like when all the build output is in one folder that way it's easier to undo/clear caches. Probably worth a discussion with the team though.
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.
I can look into this; I think it's the default, not sure if it's configureable (based on PackageEntryOptions
in SK-next). FWIW, I added a yarn clean
script to package.json
that clears away any built files/entrypoints.
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.
After seeing the use case for multiple entries into a package (eg. web-workers
), this sounds like a reasonable tradeoff.
pkg.entry({root: './src/index'});
pkg.entry({name: 'babel', root: './src/babel-plugin'});
pkg.entry({name: 'webpack', root: './src/webpack-parts'});
pkg.entry({name: 'worker', root: './src/worker'});
This whole automation of a package entry is really neat!
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.
Yeah, I don't love littering the root of a package with all its entry files, but unfortunately there's not really any other way to do multi-entry packages consistently.
@@ -0,0 +1,76 @@ | |||
{ |
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.
Does sewing-kit-next expect the tsconfig.json
to live in the root dir?
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.
Not certain, but I believe so? I remember getting some errors about not finding a quilt/tsconfig.json
when playing around with with different tsconfig.json
setups.
package.json
Outdated
"build": "sk build", | ||
"check": "lerna run check", | ||
"ci:lint-docs": "yarn generate docs && test -z \"$(git status --porcelain)\" || echo 'The root README has not been updated. Run `yarn generate docs` in the root of your quilt directory and try again.'", | ||
"clean": "rimraf './packages/*/build' './packages/*/*.d.ts' './packages/*/*.js' './packages/*/*.esnext' './packages/*/*.mjs' '.sewing-kit'", |
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.
Clearing all these files manually feels like a guessing game to me. We should rely on sewing-kit to handle this.
There are a number of files that match the following './packages/*/*.d.ts' './packages/*/*.js'
that are removed in this PR. Did any of these get accidentally picked up by a yarn run clean
or are all of them covered by sewing-kit's pkg.entry
automation?
I don't expect an answer for this 😅 Just more things to consider during our validation of sewing-kit-next.
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.
I think I deliberately got rid of some packages/*/*.d.ts
and packages/*/*.js
files (also added them to .gitignore
) since we didn't need them anymore with our new generated entrypoints, but it's probably worth it for me to go back and double-check that they were all actually just entrypoints 👍
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.
.eslintrc.js
Outdated
'plugin:@shopify/react', | ||
'plugin:@shopify/jest', | ||
'plugin:@shopify/prettier', | ||
'plugin:@sewing-kit/typescript', |
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.
You should keep the Shopify ESLint plugins, I only added a custom ESLint plugin in sewing-kit to get rid of a few rules I hate, and show how it could be authored with TypeScript (unlike our actual plugin, that's all in JS)
packages/*/*.node | ||
packages/*/*.mjs | ||
packages/*/*.d.ts | ||
packages/*/*.js |
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.
The thing to watch out for here is that we sometimes nest .eslintrc.js
or similar in subdirectories, and we do generally want to include those files.
.travis.yml
Outdated
- yarn build --verbose | ||
- yarn test:ci --testPathPattern react-server address | ||
- yarn build | ||
- yarn type-check |
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.
build
effectively includes a type-check
, because part of the build is generating the TypeScript outputs
config/sewing-kit/index.ts
Outdated
hooks.configure.hook(hooks => { | ||
hooks.jestEnvironment?.hook(() => jestEnv); | ||
|
||
hooks.jestConfig?.hook(config => ({ |
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.
There are more specific hooks for jestTransforms
and the watch ignore patterns
package.json
Outdated
"release": "yarn lint:changelogs && lerna publish", | ||
"release-beta": "lerna publish --dist-tag beta", | ||
"pretest": "yarn build", | ||
"test": "yarn _test", |
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.
I think this may be changing the default test
command to be in watch mode, which may not be desirable
@@ -3,8 +3,8 @@ | |||
"version": "2.0.1", | |||
"license": "MIT", | |||
"description": "Constants and types relating to `@shopify/address`", | |||
"main": "dist/src/index.js", | |||
"types": "dist/src/index.d.ts", | |||
"main": "index.js", |
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.
Yeah, I don't love littering the root of a package with all its entry files, but unfortunately there's not really any other way to do multi-entry packages consistently.
"main": "dist/src/index.js", | ||
"types": "dist/src/index.d.ts", | ||
"main": "index.js", | ||
"types": "index.d.ts", |
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.
For packages to get the full benefits of the different build outputs, you'll eventually need to also add esnext
/ module
entries to package.json (and, if you're interested, the future-looking exports
map). Example: https://github.com/lemonmade/quilt/blob/main/packages/quilt/package.json#L10-L32
Get rid of extra TS version
- @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected]
We're no longer using the TS builds
- @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected] - @shopify/[email protected]
Maybe discuss this approach
@@ -32,7 +32,7 @@ export const polyfills: {[polyfill: string]: PolyfillDescriptor} = { | |||
export function mappedPolyfillsForEnv( | |||
env: 'node' | 'jest' | string[], | |||
): {[key: string]: string} { | |||
const prefix = `@shopify/polyfills/build/cjs`; | |||
const prefix = `@shopify/polyfills`; |
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.
I'm wondering if it would be a terrible thing to just have the CommonJS builds for @shopify/polyfills
and just have this map to build/cjs
instead. Not sure what the impact on treeshaking would be, since this package has sideEffects
set to true
anyway.
Since the SK-next project is still in the exploration phase, we've decided to hold off on merging/releasing this until the build phase. Closing this PR for now. |
Description
Related to #1522
This PR integrates sewing-kit-next into Quilt's builds.
yarn build
yarn test
yarn lint
Some notes
watchman shutdown-server
anddev up
after restarting the terminal after a while fixes things. I suspect it may have something to do with the volume of built files (note: look into configuring Watchman)tsconfig.json
to the workspace root causes the plugin to traverse the entire workspace when you open a.ts
file not included in one of the referenced projects/packages (opening a.ts
file in a project/package loads the TS for that package only, as before). This behaviour also occurs in other similarly structured workspaces, the difference being thatShopify/quilt
is relatively large so the plugin appears to run out of memory halfway, causing it to hang and crash repeatedly. Increasing the memory limit seems to fix the problem, though it might be something to look into further