Skip to content

Commit 2b84fbe

Browse files
authored
Merge pull request #457 from stasm/ts-syntax
(@fluent/syntax) Migrate to TypeScript
2 parents 8c38be9 + 9d7e7a2 commit 2b84fbe

39 files changed

+994
-747
lines changed

fluent-gecko/makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Fluent.jsm: $(SOURCES)
2323
@echo -e " $(OK) $@ built"
2424

2525
FluentSyntax.jsm: $(SOURCES)
26+
$(MAKE) -sC ../fluent-syntax compile
2627
@rollup $(CURDIR)/src/fluent_syntax.js \
2728
--config ./xpcom_config.js \
2829
--no-treeshake \

fluent-gecko/src/fluent_syntax.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
comma-dangle: "off",
33
no-labels: "off" */
44

5-
import {FluentParser} from "../../fluent-syntax/src/parser";
6-
import {FluentSerializer} from "../../fluent-syntax/src/serializer";
7-
import * as ast from "../../fluent-syntax/src/ast";
8-
import * as visitor from "../../fluent-syntax/src/visitor";
5+
import {FluentParser} from "../../fluent-syntax/esm/parser";
6+
import {FluentSerializer} from "../../fluent-syntax/esm/serializer";
7+
import {Visitor, Transformer} from "../../fluent-syntax/esm/visitor";
8+
import * as ast from "../../fluent-syntax/esm/ast";
99

1010
this.EXPORTED_SYMBOLS = [
11+
...Object.keys(ast),
1112
...Object.keys({
1213
FluentParser,
1314
FluentSerializer,
15+
Visitor,
16+
Transformer
1417
}),
15-
...Object.keys(ast),
16-
...Object.keys(visitor),
1718
];

fluent-syntax/.esdoc.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

fluent-syntax/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
esm/
12
/index.js
23
/compat.js

fluent-syntax/.npmignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
.nyc_output
22
coverage
3-
docs
3+
esm/.compiled
4+
src
45
test
56
makefile
7+
tsconfig.json

fluent-syntax/makefile

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,61 @@ GLOBAL := FluentSyntax
33

44
include ../common.mk
55

6-
test:
6+
lint:
7+
@eslint --config $(ROOT)/eslint_ts.json --max-warnings 0 src/*.ts
8+
@eslint --config $(ROOT)/eslint_test.json --max-warnings 0 test/
9+
@echo -e " $(OK) lint"
10+
11+
.PHONY: compile
12+
compile: esm/.compiled
13+
14+
esm/.compiled: $(SOURCES)
15+
@tsc
16+
@touch $@
17+
@echo -e " $(OK) esm/ compiled"
18+
19+
.PHONY: test
20+
test: esm/.compiled
721
@nyc --reporter=text --reporter=html mocha \
822
--recursive --ui tdd \
923
--require esm \
1024
test/**/*_test.js
1125

1226
build: index.js compat.js
1327

14-
index.js: $(SOURCES)
15-
@rollup $(CURDIR)/src/index.js \
28+
index.js: esm/.compiled
29+
@rollup $(CURDIR)/esm/index.js \
1630
--config $(ROOT)/bundle_config.js \
1731
--banner "/* $(PACKAGE)@$(VERSION) */" \
1832
--amd.id $(PACKAGE) \
1933
--name $(GLOBAL) \
2034
--output.file $@
2135
@echo -e " $(OK) $@ built"
2236

23-
compat.js: $(SOURCES)
24-
@rollup $(CURDIR)/src/index.js \
37+
compat.js: esm/.compiled
38+
@rollup $(CURDIR)/esm/index.js \
2539
--config $(ROOT)/compat_config.js \
2640
--banner "/* $(PACKAGE)@$(VERSION) */" \
2741
--amd.id $(PACKAGE) \
2842
--name $(GLOBAL) \
2943
--output.file $@
3044
@echo -e " $(OK) $@ built"
3145

32-
lint: _lint
33-
html: _html
34-
clean: _clean
46+
html:
47+
@typedoc src \
48+
--out ../html/syntax \
49+
--mode file \
50+
--excludeNotExported \
51+
--excludePrivate \
52+
--logger none \
53+
--hideGenerator
54+
@echo -e " $(OK) html built"
55+
56+
clean:
57+
@rm -f esm/*.js esm/*.d.ts esm/.compiled
58+
@rm -f index.js compat.js
59+
@rm -rf .nyc_output coverage
60+
@echo -e " $(OK) clean"
3561

3662
STRUCTURE_FTL := $(wildcard test/fixtures_structure/*.ftl)
3763
STRUCTURE_AST := $(STRUCTURE_FTL:.ftl=.json)

fluent-syntax/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515
"email": "[email protected]"
1616
}
1717
],
18-
"directories": {
19-
"lib": "./src"
20-
},
18+
"type": "commonjs",
2119
"main": "./index.js",
22-
"module": "./src/index.js",
20+
"module": "./esm/index.js",
21+
"types": "./esm/index.d.ts",
2322
"repository": {
2423
"type": "git",
2524
"url": "https://github.com/projectfluent/fluent.js.git"

0 commit comments

Comments
 (0)