Skip to content

Commit

Permalink
Flatten lib bundle (#11)
Browse files Browse the repository at this point in the history
A prominent pain point I've observed working with seek-module-toolkit is
that it compiles to nested directories like `/lib/commonjs`. This means
that the depth of the compiled file differs from the source file under
`/src`, which can make bundling and referencing of non-JS assets more of
a hassle than it should be.

I propose that we instead compile to `/lib-commonjs`, and document this
as a potential breaking change when migrating from seek-module-toolkit.
skuba itself moves to this model as a guinea pig.

I've taken this opportunity to revise the ignore files to account for
proposed directories like `/lib-commonjs`.
  • Loading branch information
72636c authored Jun 7, 2020
1 parent 0d3f0ad commit 3f4bb58
Show file tree
Hide file tree
Showing 17 changed files with 106 additions and 142 deletions.
8 changes: 8 additions & 0 deletions .changeset/clean-cooks-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'skuba': patch
---

**configure, init:** Tweak ignore file patterns

Directory names like `/lib-es2015` are ignored based on prefix now,
but certain patterns have been restricted to the root to allow for `/src/lib`.
12 changes: 6 additions & 6 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.idea/
.serverless/
.vscode/
coverage/
dist/
lib/
node_modules/
node_modules_bak/
tmp/
node_modules*/

/coverage*/
/dist*/
/lib*/
/tmp*/

.DS_Store
.npmrc
Expand Down
15 changes: 5 additions & 10 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
.idea/
.serverless/
.vscode/
coverage/
dist/
lib/
node_modules/
node_modules_bak/
tmp/
node_modules*/

.DS_Store
.npmrc
npm-debug.log
yarn-error.log
/coverage*/
/dist*/
/lib*/
/tmp*/

/template/
13 changes: 6 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
.idea/
.serverless/
.vscode/
coverage/
dist/
lib/
node_modules/
node_modules_bak/
tmp/
tmp-*/
node_modules*/

/coverage*/
/dist*/
/lib*/
/tmp*/

.DS_Store
.npmrc
Expand Down
18 changes: 0 additions & 18 deletions .npmignore

This file was deleted.

12 changes: 6 additions & 6 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.idea/
.serverless/
.vscode/
coverage/
dist/
lib/
node_modules/
node_modules_bak/
tmp/
node_modules*/

/coverage*/
/dist*/
/lib*/
/tmp*/

.DS_Store
.npmrc
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ By convention, this points to a `tsconfig.build.json` that excludes tests from y
```jsonc
// tsconfig.json
{
"compilerOptions": {},
"compilerOptions": {
"outDir": "lib"
},
"exclude": ["lib/**/*"]
}
```
Expand Down
13 changes: 9 additions & 4 deletions config/jest.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
module.exports = {
collectCoverageFrom: [
'**/*.ts',
'!**/node_modules/**',
'!<rootDir>/coverage/**',
'!<rootDir>/lib/**',
'!**/node_modules*/**',
'!<rootDir>/coverage*/**',
'!<rootDir>/dist*/**',
'!<rootDir>/lib*/**',
'!<rootDir>/tmp*/**',
],
coverageDirectory: 'coverage',
moduleNameMapper: {
Expand All @@ -12,5 +14,8 @@ module.exports = {
},
preset: 'skuba',
testEnvironment: 'node',
testPathIgnorePatterns: ['/node_modules/', '<rootDir>/lib/'],
testPathIgnorePatterns: [
'/node_modules.*/',
'<rootDir>/(coverage|dist|lib|tmp).*/',
],
};
14 changes: 8 additions & 6 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@ module.exports = {
collectCoverageFrom: [
'**/*.ts',
'!**/node_modules/**',
'!<rootDir>/lib/**',
'!<rootDir>/coverage/**',
'!<rootDir>/template/**',
'!<rootDir>/coverage*/**',
'!<rootDir>/dist*/**',
'!<rootDir>/lib*/**',
'!<rootDir>/tmp*/**',
],
coverageDirectory: 'coverage',
preset: 'ts-jest',
setupFiles: ['<rootDir>/jest.setup.ts'],
testEnvironment: 'node',
testPathIgnorePatterns: [
'/node_modules/',
'/test.ts',
'<rootDir>/lib/',
'/node_modules.*/',
'<rootDir>/(coverage|dist|lib|tmp).*/',

'<rootDir>/template/',
'/test\\.ts',
],
};
21 changes: 9 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,27 @@
"name": "skuba",
"description": "Toolkit for backend TypeScript development",
"bin": {
"skuba": "lib/commonjs/skuba.js"
"skuba": "lib-commonjs/skuba.js"
},
"engines": {
"node": ">=12"
},
"version": "3.4.1",
"main": "lib/commonjs",
"module": "lib/es2015",
"typings": "lib/index.d.ts",
"main": "lib-commonjs",
"module": "lib-es2015",
"typings": "lib-types/index.d.ts",
"files": [
"config/**/*",
"lib/**/*.d.ts",
"lib/**/*.js",
"lib/**/*.js.map",
"lib/template/**/*",
"lib*/**/*.d.ts",
"lib*/**/*.js",
"lib*/**/*.js.map",
"template/**/*",
"jest-preset.js"
],
"sideEffects": false,
"license": "MIT",
"scripts": {
"build": "concurrently yarn:build:* && scripts/postbuild.sh",
"build:commonjs": "tsc --module CommonJS --outDir lib/commonjs --project tsconfig.build.json",
"build:declaration": "tsc --allowJS false --declaration --emitDeclarationOnly --project tsconfig.build.json",
"build:es2015": "tsc --module ES2015 --outDir lib/es2015 --project tsconfig.build.json",
"build": "yarn skuba build-package && scripts/postbuild.sh",
"format": "yarn skuba format",
"lint": "yarn skuba lint",
"release": "yarn build && changeset publish",
Expand Down
4 changes: 1 addition & 3 deletions scripts/postbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

set -e

cp -r template lib

chmod +x 'lib/commonjs/skuba.js'
chmod +x 'lib-commonjs/skuba.js'
54 changes: 22 additions & 32 deletions src/cli/configure/analysis/__snapshots__/project.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ Object {
"data": ".idea/
.serverless/
.vscode/
coverage/
dist/
lib/
node_modules/
node_modules_bak/
tmp/
node_modules*/
/coverage*/
/dist*/
/lib*/
/tmp*/
.DS_Store
.npmrc
Expand All @@ -24,17 +24,12 @@ yarn-error.log
"data": ".idea/
.serverless/
.vscode/
coverage/
dist/
lib/
node_modules/
node_modules_bak/
tmp/
node_modules*/
.DS_Store
.npmrc
npm-debug.log
yarn-error.log
/coverage*/
/dist*/
/lib*/
/tmp*/
",
"operation": "A",
},
Expand All @@ -56,12 +51,12 @@ yarn-error.log
"data": ".idea/
.serverless/
.vscode/
coverage/
dist/
lib/
node_modules/
node_modules_bak/
tmp/
node_modules*/
/coverage*/
/dist*/
/lib*/
/tmp*/
.DS_Store
.npmrc
Expand All @@ -76,17 +71,12 @@ yarn-error.log
"data": ".idea/
.serverless/
.vscode/
coverage/
dist/
lib/
node_modules/
node_modules_bak/
tmp/
node_modules*/
.DS_Store
.npmrc
npm-debug.log
yarn-error.log
/coverage*/
/dist*/
/lib*/
/tmp*/
# Gantry resource files support non-standard template syntax
gantry*.yaml
Expand Down
12 changes: 6 additions & 6 deletions template/base/_.dockerignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.idea/
.serverless/
.vscode/
coverage/
dist/
lib/
node_modules/
node_modules_bak/
tmp/
node_modules*/

/coverage*/
/dist*/
/lib*/
/tmp*/

.DS_Store
.npmrc
Expand Down
15 changes: 5 additions & 10 deletions template/base/_.eslintignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
.idea/
.serverless/
.vscode/
coverage/
dist/
lib/
node_modules/
node_modules_bak/
tmp/
node_modules*/

.DS_Store
.npmrc
npm-debug.log
yarn-error.log
/coverage*/
/dist*/
/lib*/
/tmp*/
12 changes: 6 additions & 6 deletions template/base/_.gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.idea/
.serverless/
.vscode/
coverage/
dist/
lib/
node_modules/
node_modules_bak/
tmp/
node_modules*/

/coverage*/
/dist*/
/lib*/
/tmp*/

.DS_Store
.npmrc
Expand Down
15 changes: 5 additions & 10 deletions template/base/_.prettierignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
.idea/
.serverless/
.vscode/
coverage/
dist/
lib/
node_modules/
node_modules_bak/
tmp/
node_modules*/

.DS_Store
.npmrc
npm-debug.log
yarn-error.log
/coverage*/
/dist*/
/lib*/
/tmp*/

# Gantry resource files support non-standard template syntax
gantry*.yaml
Expand Down
6 changes: 1 addition & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@
"compilerOptions": {
"baseUrl": "src",
"incremental": true,
"outDir": "lib",
"moduleResolution": "node",
"paths": {
"enquirer": ["enquirer"]
},
"removeComments": false
},
"exclude": ["lib/**/*", "template/**/*"],
"exclude": ["lib*/**/*", "template/**/*"],
"extends": "./config/tsconfig.json"
}

0 comments on commit 3f4bb58

Please sign in to comment.