Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

[quilt] Build Quilt using sewing-kit-next #1538

Closed
wants to merge 41 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
46a2ae8
Update ignore files, lint and prettier configs
Jul 28, 2020
d5b5398
Update package.json
Jul 28, 2020
d3369ad
Update CI config
Jul 28, 2020
dc87d4d
Delete unneeded Babel and Jest config files
Jul 28, 2020
e612ef4
Add/update generators
Jul 28, 2020
28b3518
Add CI scripts
Jul 28, 2020
588d4ef
Move TS config to root
Jul 28, 2020
5fba41a
Add workspace lint TS config
Jul 28, 2020
84622f8
Rename test configs
Jul 28, 2020
65ec17e
Update VS Code settings
Jul 28, 2020
79eb093
Move and rename base TS config
Jul 28, 2020
822ade7
Update docs
Jul 28, 2020
db8c6ba
Add SK-next configs
Jul 28, 2020
34f0a56
Polish docs
Jul 28, 2020
9c9b673
Update and move repo tests and testing setup
Jul 28, 2020
98f8551
Update templates
Jul 28, 2020
6adfff1
Update tests, code
Jul 28, 2020
37d56a1
Add package-level SK-next configs
Jul 28, 2020
400948e
Update yarn.lock
Jul 28, 2020
09e6ac8
Resolve Babel plugin
Jul 29, 2020
b9ec759
Clean up
Jul 29, 2020
a90b61a
Get rid of unused config file
Jul 29, 2020
3800d9b
Get rid of unused package
Jul 29, 2020
476bf9a
Update "dist"
Jul 30, 2020
e91936a
Use type export
Aug 6, 2020
90e4791
Replace index field with dot
Aug 6, 2020
7627403
Publish
Aug 6, 2020
c369a9b
Polish
Aug 6, 2020
af635bb
Add changelog entries
Aug 6, 2020
512eef3
Change polyfill root to be CJS build, not TS
Aug 6, 2020
3446887
Fix test
Aug 7, 2020
2c3068c
Exclude non-suite test files
Aug 8, 2020
b810499
Fix test
Aug 8, 2020
c9b69a0
Enforce isolatedModules
Aug 10, 2020
07876a2
Get rid of tslib
Aug 10, 2020
1a6fdfc
Publish
Aug 10, 2020
cfb151b
Fix entrypoints for polyfills package
Aug 10, 2020
d68b3f0
Revert beta publish commits
Aug 11, 2020
bdbfa7c
Clean up
Aug 13, 2020
52125bd
Fix script
Aug 13, 2020
06d55bc
Fix changelogs
Aug 13, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 7 additions & 5 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
node_modules
coverage
**/node_modules/*
**/packages/*.js
*.d.ts
**/templates/*
**/dummy/**
templates
gems/**/dummy
packages/*/build
**/*.d.ts
**/*.js
**/*.esnext
**/*.mjs
8 changes: 2 additions & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ module.exports = {
'plugin:@shopify/prettier',
],
parserOptions: {
project: [
'packages/tsconfig.json',
'packages/tsconfig_base.json',
'test/tsconfig.eslint.json',
],
project: ['./tsconfig.eslint.json'],
},
rules: {
'jest/valid-expect-in-promise': 'off',
Expand All @@ -34,7 +30,6 @@ module.exports = {
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/await-thenable': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'import/no-extraneous-dependencies': 'error',
},
overrides: [
Expand All @@ -44,6 +39,7 @@ module.exports = {
'**/test/**/*.tsx',
'**/tests/**/*.ts',
'**/tests/**/*.tsx',
'**/sewing-kit.config.ts',
],
rules: {
// We disable `import/no-extraneous-dependencies` for test files because it
Expand Down
15 changes: 11 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
*.scss.d.ts
*.graphql.d.ts

#TS output
packages/**/dist
dist

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

Expand Down Expand Up @@ -44,3 +40,14 @@ tmp
**/test.log

*.tsbuildinfo

# Sewing-Kit builds and entrypoints
.sewing-kit
packages/*/build
packages/*/*.esnext
packages/*/*.mjs
packages/*/*.d.ts
packages/*/*.js
Copy link
Member

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.

!packages/*/.eslintrc.js

.package-build-cache
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package.json
node_modules
dist
packages/*/build
coverage
*.svg
templates/*.md
Expand Down
14 changes: 11 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,20 @@ matrix:
- <<: *node_container
name: 'Node - build, type-check, and end-to-end tests'
script:
- yarn build --verbose
- yarn test:ci --testPathPattern react-server address
- yarn build
- yarn ci:test "(address|react-server)"
cache:
directories:
- .sewing-kit
- .package-build-cache
before-cache:
- ./scripts/copy_build_to_cache.sh
before-script:
- ./scripts/copy_cache_to_build.sh
- <<: *node_container
name: 'Node - unit tests'
script:
- yarn test:ci --testPathIgnorePatterns react-server address
- yarn ci:test "^(?:(?!(address|react-server)).)*$"
- yarn codecov
- <<: *node_container
name: 'Node - lint'
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"build": true,
"**/*.js": true
},
"typescript.tsserver.maxTsServerMemory": 8000,
Copy link
Contributor

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.

Copy link
Contributor Author

@b-ryu b-ryu Jul 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing:

  1. Pull this branch down and open it in VS Code
  2. Get rid of the typescript.tsserver.maxTsServerMemory setting fix
  3. Close all tabs in and close VS Code
  4. Open Quilt in VS Code
  5. Open sewing-kit.config.ts in the workspace root
  6. 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

Screen Shot 2020-07-22 at 2 52 57 PM

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.

Copy link
Contributor

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 :/

Copy link
Contributor Author

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?

Copy link
Contributor

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

"editor.formatOnSave": true,
"prettier-stylelint.stylelintIntegration": true,
"prettier-eslint.eslintIntegration": true,
Expand Down
7 changes: 0 additions & 7 deletions babel.config.js

This file was deleted.

13 changes: 0 additions & 13 deletions config/eslint.js

This file was deleted.

62 changes: 62 additions & 0 deletions config/sewing-kit/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import {
Package,
createComposedProjectPlugin,
createProjectTestPlugin,
createProjectBuildPlugin,
} from '@sewing-kit/plugins';
import {react} from '@sewing-kit/plugin-react';
Copy link
Contributor

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?

Copy link
Contributor

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

Copy link
Member

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.

import {javascript, updateBabelPreset} from '@sewing-kit/plugin-javascript';
import {typescript} from '@sewing-kit/plugin-typescript';
import {buildFlexibleOutputs} from '@sewing-kit/plugin-package-flexible-outputs';
import {} from '@sewing-kit/plugin-jest';

import {addLegacyDecoratorSupport} from './plugins';

export function quiltPackage({jestEnv = 'jsdom', useReact = false} = {}) {
return createComposedProjectPlugin<Package>('Quilt.Package', [
javascript(),
typescript(),
useReact && react(),
buildFlexibleOutputs(),
createProjectBuildPlugin('Quilt.PackageBuild', ({hooks}) => {
hooks.target.hook(({hooks}) => {
hooks.configure.hook(hooks => {
hooks.babelIgnorePatterns?.hook(ext => [
...ext,
'**/test/**/*',
'**/tests/**/*',
]);

hooks.babelConfig?.hook(addLegacyDecoratorSupport);
});
});
}),
createProjectTestPlugin('Quilt.PackageTest', ({hooks}) => {
hooks.configure.hook(hooks => {
hooks.jestEnvironment?.hook(() => jestEnv);

hooks.jestTransforms?.hook(transforms => ({
...transforms,
'\\.(gql|graphql)$': 'jest-transform-graphql',
}));

hooks.jestWatchIgnore?.hook(patterns => [
...patterns,
'<rootDir>/.*/tests?/.*fixtures',
]);

hooks.babelConfig?.hook(addLegacyDecoratorSupport);
// Each test imports from react-testing during setup
hooks.babelConfig?.hook(
updateBabelPreset(
['@babel/preset-react', require.resolve('@babel/preset-react')],
{
development: false,
useBuiltIns: true,
},
),
);
});
}),
]);
}
23 changes: 23 additions & 0 deletions config/sewing-kit/plugins.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {BabelConfig, updateBabelPlugin} from '@sewing-kit/plugin-javascript';

export async function addLegacyDecoratorSupport(config: BabelConfig) {
return updateBabelPlugin(
[
'@babel/plugin-proposal-decorators',
require.resolve('@babel/plugin-proposal-decorators'),
],
() => ({
legacy: true,
}),
)(
await updateBabelPlugin(
[
'@babel/plugin-proposal-class-properties',
require.resolve('@babel/plugin-proposal-class-properties'),
],
{
loose: true,
},
)(config),
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
"downlevelIteration": true,
"esModuleInterop": true,
"jsx": "react",
"isolatedModules": true,
"strictNullChecks": true,
"noImplicitAny": false,
"sourceMap": false,
"noEmitOnError": false,
"experimentalDecorators": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"importHelpers": true,
"lib": [
"dom",
"dom.iterable",
Expand All @@ -27,6 +27,6 @@
"es2018",
"esnext.asynciterable"
],
"typeRoots": ["../node_modules/@types"]
"typeRoots": ["../../node_modules/@types"]
}
}
2 changes: 1 addition & 1 deletion documentation/guides/package-deprecation.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Leaving only `README.md` and `CHANGELOG.md`

## 3. Delete TS package project reference

Delete the line referencing the deprecate package from [`packages/tsconfig.json`](../../packages/tsconfig.json)
Delete the line referencing the deprecate package from [`tsconfig.json`](../../tsconfig.json)

## 4. Global search deprecate package in quilt

Expand Down
2 changes: 1 addition & 1 deletion gems/quilt_rails/test/support/generator_test_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def provide_existing_app_config_file
end

def provide_existing_sewing_kit_config_file
copy_to_generator_root("config", "sewing-kit.config.ts")
copy_to_generator_root("config", "sewing-kit.testconfig.ts")
end

private
Expand Down
53 changes: 0 additions & 53 deletions jest.config.js

This file was deleted.

Loading