Skip to content

Commit c31c0b6

Browse files
Alex Eaglealexeagle
authored andcommitted
fix(docs): fix regex that replaces //packages with @bazel
It was producing wrong outputs that dropped one path segment. Also add a better error if the terser_bin attribute is missing (when not in a repo named @npm)
1 parent ea168a7 commit c31c0b6

9 files changed

Lines changed: 21 additions & 18 deletions

File tree

docs/Concatjs.html

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

docs/Concatjs.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,14 @@ Defaults to `[]`
204204

205205
Defaults to precompiled go binary setup by @bazel/typescript npm package
206206

207-
Defaults to `@npm//@bazel/devserver:devserver`
207+
Defaults to `@npm//@bazel/concatjs/devserver:devserver`
208208

209209
<h4 id="concatjs_devserver-devserver_host">devserver_host</h4>
210210

211211
(*<a href="https://bazel.build/docs/build-ref.html#labels">Label</a>*): Go based devserver executable for the host platform.
212212
Defaults to precompiled go binary setup by @bazel/typescript npm package
213213

214-
Defaults to `@npm//@bazel/devserver:devserver_darwin_amd64`
214+
Defaults to `@npm//@bazel/concatjs/devserver:devserver_darwin_amd64`
215215

216216
<h4 id="concatjs_devserver-entry_module">entry_module</h4>
217217

docs/Rollup.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/Rollup.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ Defaults to `@npm//rollup/bin:rollup`
335335

336336
(*<a href="https://bazel.build/docs/build-ref.html#labels">Label</a>*): Internal use only
337337

338-
Defaults to `@npm//@bazel/bin:rollup-worker`
338+
Defaults to `@npm//@bazel/rollup/bin:rollup-worker`
339339

340340
<h4 id="rollup_bundle-silent">silent</h4>
341341

docs/Terser.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/Terser.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,6 @@ If you want to do this, you can pass a filegroup here.
144144

145145
(*<a href="https://bazel.build/docs/build-ref.html#labels">Label</a>*): An executable target that runs Terser
146146

147-
Defaults to `@npm//@bazel/bin:terser`
147+
Defaults to `@npm//@bazel/terser/bin:terser`
148148

149149

docs/install.html

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

packages/terser/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,12 @@ function main() {
165165
// If necessary, get the new `terser` binary, added for >=4.3.0
166166
terserBinary = terserBinary || require.resolve('terser/bin/terser');
167167
} catch (e) {
168-
// If necessary, get the old `uglifyjs` binary from <4.3.0
169-
terserBinary = terserBinary || require.resolve('terser/bin/uglifyjs');
168+
try {
169+
// If necessary, get the old `uglifyjs` binary from <4.3.0
170+
terserBinary = terserBinary || require.resolve('terser/bin/uglifyjs');
171+
} catch (e) {
172+
throw new Error('terser binary not found. Maybe you need to set the terser_bin attribute?')
173+
}
170174
}
171175
// choose a default concurrency of the number of cores -1 but at least 1.
172176

@@ -194,4 +198,4 @@ exports.directoryArgs = directoryArgs;
194198

195199
if (require.main === module) {
196200
main();
197-
}
201+
}

tools/stardoc/post-process-docs.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ const content = readFileSync(md, {encoding: 'utf8'});
77
// @npm is not the required name, but it seems to be the common case
88
// this reflects the similar transformation made when publishing the packages to npm
99
// via pkg_npm defined in //tools:defaults.bzl
10-
const out = content
11-
.replace(/(?:@.*)*?\/\/packages\/([^:"\s]*)/g, (str, pkg) => {
12-
const parts = pkg.split('/');
13-
return `@npm//@bazel/${parts[parts.length - 1]}`;
14-
});
10+
const out = content.replace(/(?:@.*)*?\/\/packages\/([^/:"\s]*)/g, (str, pkg) => {
11+
const parts = pkg.split('/');
12+
return `@npm//@bazel/${parts[parts.length - 1]}`;
13+
});
1514

1615
// stamp the frontmatter into the post processed stardoc HTML
1716
const frontmatter = [

0 commit comments

Comments
 (0)