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

Commit

Permalink
Merge pull request #1698 from Shopify/multi-build-support
Browse files Browse the repository at this point in the history
Multi-build support (cjs, esm, esnext) for all quilt packages
  • Loading branch information
ismail-syed authored Dec 21, 2020
2 parents 97cbe62 + eae1ebf commit 561d741
Show file tree
Hide file tree
Showing 406 changed files with 4,267 additions and 2,647 deletions.
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
55 changes: 51 additions & 4 deletions .github/workflows/node-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ jobs:
restore-keys: |
${{ runner.os }}-yarn-
- uses: actions/cache@v2
id: sewing-kit-cache
name: Restore sewing-kit cache
with:
path: |
.sewing-kit/
key: ${{ runner.os }}-sewing-kit-${{ github.sha }}
restore-keys: |
${{ runner.os }}-sewing-kit-
- name: 📦 Install dependencies
run: yarn --production=false --frozen-lockfile

Expand Down Expand Up @@ -67,11 +77,22 @@ jobs:
restore-keys: |
${{ runner.os }}-yarn-
- uses: actions/cache@v2
id: build-cache
name: Restore build cache
with:
path: |
.sewing-kit/
./packages/*/build/
key: ${{ runner.os }}-build-${{ github.sha }}
restore-keys: |
${{ runner.os }}-build-
- name: 📦 Install dependencies
run: yarn --production=false --frozen-lockfile

- name: 🔨 Build
run: yarn build --verbose
run: yarn build

node-e2e-tests:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -101,14 +122,29 @@ jobs:
restore-keys: |
${{ runner.os }}-yarn-
- uses: actions/cache@v2
id: build-cache
name: Restore build cache
with:
# index packages files need to be cached for e2e tests
path: |
.sewing-kit/
./packages/*/build/
./packages/*/*.esnext
./packages/*/*.mjs
./packages/*/*.js
key: ${{ runner.os }}-build-${{ github.sha }}
restore-keys: |
${{ runner.os }}-build-
- name: 📦 Install dependencies
run: yarn --production=false --frozen-lockfile

- name: 🔨 Build
run: yarn build --verbose
run: yarn build

- name: E2E tests
run: yarn test:ci --testPathPattern react-server address
run: yarn test --debug "(address|react-server)"

node-unit-tests:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -139,8 +175,19 @@ jobs:
restore-keys: |
${{ runner.os }}-yarn-
- uses: actions/cache@v2
id: build-cache
name: Restore build cache
with:
path: |
.sewing-kit/
./packages/*/build/
key: ${{ runner.os }}-build-${{ github.sha }}
restore-keys: |
${{ runner.os }}-build-
- name: 📦 Install dependencies
run: yarn --production=false --frozen-lockfile

- name: Unit tests
run: yarn test:ci --testPathIgnorePatterns react-server address
run: yarn test:ci "^(?:(?!(address|react-server)).)*$"
19 changes: 15 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,18 @@ tmp
**/test.log

*.tsbuildinfo

# Sewing-Kit builds and entrypoints
.sewing-kit
packages/*/build
packages/*/*.esnext
packages/*/*.mjs
packages/*/*.d.ts
packages/*/*.js
!packages/*/.eslintrc.js

## Remove me after sk-next migration
packages/**/dist
dist

.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
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,
"editor.formatOnSave": true,
"prettier-stylelint.stylelintIntegration": true,
"prettier-eslint.eslintIntegration": true,
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ These libraries compose together to help you create performant modern JS apps th

## Usage

The Quilt repo is managed as a monorepo that is composed of 70 npm packages and one Ruby gem.
The Quilt repo is managed as a monorepo that is composed of 69 npm packages and one Ruby gem.
Each package/gem has its own `README.md` and documentation describing usage.

### Package Index
Expand Down
13 changes: 0 additions & 13 deletions config/eslint.js

This file was deleted.

63 changes: 63 additions & 0 deletions config/sewing-kit/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import {
Package,
createComposedProjectPlugin,
createProjectTestPlugin,
createProjectBuildPlugin,
} from '@sewing-kit/plugins';
import {react} from '@sewing-kit/plugin-react';
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 './plugin';

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/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {BabelConfig, updateBabelPlugin} from '@sewing-kit/plugin-javascript';

export function addLegacyDecoratorSupport(config: BabelConfig) {
return updateBabelPlugin(
[
'@babel/plugin-proposal-class-properties',
require.resolve('@babel/plugin-proposal-class-properties'),
],
{
loose: true,
},
)(config).then(babelConfig => {
return updateBabelPlugin(
[
'@babel/plugin-proposal-decorators',
require.resolve('@babel/plugin-proposal-decorators'),
],
() => ({
legacy: true,
}),
)(babelConfig);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"downlevelIteration": true,
"esModuleInterop": true,
"jsx": "react",
"isolatedModules": true,
"strictNullChecks": true,
"noImplicitAny": false,
"sourceMap": false,
Expand All @@ -27,6 +28,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

0 comments on commit 561d741

Please sign in to comment.