Skip to content

Commit 1c0ebaf

Browse files
author
unennhexium
committed
Implement monorepo build example
1 parent d415e7d commit 1c0ebaf

File tree

13 files changed

+148
-10
lines changed

13 files changed

+148
-10
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
.idea
33
node_modules
44
package-lock.json
5+
pnpm-lock.yaml
56
dist

index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,12 @@ export const typescriptPaths = ({
6969
? resolvedFileName
7070
: resolvedFileName.replace(/\.tsx?$/i, '.js');
7171

72-
/* Do not use:
72+
/*
73+
* Do not use:
7374
* - path.dirname(tsConfigPath) -> using abs. path to <proj_root>/test/<tsconfig>
74-
* - __dirname -> using abs. path to compiled plugin files <proj_root>/dist
75-
* - process.env.PWD -> non cross-platform
76-
* instead of process.cwd() -> using abs. path to <proj_root>/<tsconfig>, that is correct
75+
* - __dirname -> using abs. path to compiled plugin files <proj_root>/dist
76+
* - process.env.PWD -> non cross-platform
77+
* instead of process.cwd() -> using abs. path to <proj_root>/<tsconfig>, that is correct
7778
*/
7879
const targetFileName = typeof compilerOptions.baseUrl === 'undefined'
7980
? join(outDir, relative(process.cwd(), processedFileName))

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
"files": [
88
"dist"
99
],
10+
"workspaces": [ "test" ],
1011
"scripts": {
12+
"test:mono-error": "npm run build:error --workspaces",
13+
"test:mono": "npm run build --workspaces",
1114
"test:wo-baseurl": "WO_BASEURL=true npm run test",
1215
"test": "npm run prepare && node test",
1316
"preversion": "npm test",

pnpm-lock.yaml

Lines changed: 73 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/bar/foo.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.bar = void 0;
4+
exports.bar = 'foo';

test/foo/bar-react.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.foo = void 0;
4+
exports.foo = 'bar';

test/foo/bar.d.ts

Whitespace-only changes.

test/foo/bar.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.foo = void 0;
4+
exports.foo = 'bar';

test/main.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.default = exports.bak = exports.bar = exports.baz = exports.foo = void 0;
4+
var _foobar_1 = require("@foobar");
5+
Object.defineProperty(exports, "foo", { enumerable: true, get: function () { return _foobar_1.foo; } });
6+
var _foobar_react_1 = require("@foobar-react");
7+
Object.defineProperty(exports, "baz", { enumerable: true, get: function () { return _foobar_react_1.foo; } });
8+
var foo_1 = require("@bar/foo");
9+
Object.defineProperty(exports, "bar", { enumerable: true, get: function () { return foo_1.bar; } });
10+
var foo_2 = require("bar/foo");
11+
Object.defineProperty(exports, "bak", { enumerable: true, get: function () { return foo_2.bar; } });
12+
var _js_1 = require("@js");
13+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return _js_1.default; } });

test/main.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export { foo } from '@foobar'
2+
export { foo as baz } from '@foobar-react'
3+
export { bar } from '@bar/foo'
4+
export { bar as bak } from 'bar/foo'
5+
export { default } from '@js'

0 commit comments

Comments
 (0)