Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(@fluent/syntax) Migrate to TypeScript #457

Merged
merged 9 commits into from
Mar 2, 2020
1 change: 1 addition & 0 deletions fluent-gecko/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Fluent.jsm: $(SOURCES)
@echo -e " $(OK) $@ built"

FluentSyntax.jsm: $(SOURCES)
$(MAKE) -sC ../fluent-syntax compile
@rollup $(CURDIR)/src/fluent_syntax.js \
--config ./xpcom_config.js \
--no-treeshake \
Expand Down
13 changes: 7 additions & 6 deletions fluent-gecko/src/fluent_syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
comma-dangle: "off",
no-labels: "off" */

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

this.EXPORTED_SYMBOLS = [
...Object.keys(ast),
...Object.keys({
FluentParser,
FluentSerializer,
Visitor,
Transformer
}),
...Object.keys(ast),
...Object.keys(visitor),
];
16 changes: 0 additions & 16 deletions fluent-syntax/.esdoc.json

This file was deleted.

1 change: 1 addition & 0 deletions fluent-syntax/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
esm/
/index.js
/compat.js
4 changes: 3 additions & 1 deletion fluent-syntax/.npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.nyc_output
coverage
docs
esm/.compiled
src
test
makefile
tsconfig.json
42 changes: 34 additions & 8 deletions fluent-syntax/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,61 @@ GLOBAL := FluentSyntax

include ../common.mk

test:
lint:
@eslint --config $(ROOT)/eslint_ts.json --max-warnings 0 src/*.ts
@eslint --config $(ROOT)/eslint_test.json --max-warnings 0 test/
@echo -e " $(OK) lint"

.PHONY: compile
compile: esm/.compiled

esm/.compiled: $(SOURCES)
@tsc
@touch $@
@echo -e " $(OK) esm/ compiled"

.PHONY: test
test: esm/.compiled
@nyc --reporter=text --reporter=html mocha \
--recursive --ui tdd \
--require esm \
test/**/*_test.js

build: index.js compat.js

index.js: $(SOURCES)
@rollup $(CURDIR)/src/index.js \
index.js: esm/.compiled
@rollup $(CURDIR)/esm/index.js \
--config $(ROOT)/bundle_config.js \
--banner "/* $(PACKAGE)@$(VERSION) */" \
--amd.id $(PACKAGE) \
--name $(GLOBAL) \
--output.file $@
@echo -e " $(OK) $@ built"

compat.js: $(SOURCES)
@rollup $(CURDIR)/src/index.js \
compat.js: esm/.compiled
@rollup $(CURDIR)/esm/index.js \
--config $(ROOT)/compat_config.js \
--banner "/* $(PACKAGE)@$(VERSION) */" \
--amd.id $(PACKAGE) \
--name $(GLOBAL) \
--output.file $@
@echo -e " $(OK) $@ built"

lint: _lint
html: _html
clean: _clean
html:
@typedoc src \
--out ../html/syntax \
--mode file \
--excludeNotExported \
--excludePrivate \
--logger none \
--hideGenerator
@echo -e " $(OK) html built"

clean:
@rm -f esm/*.js esm/*.d.ts esm/.compiled
@rm -f index.js compat.js
@rm -rf .nyc_output coverage
@echo -e " $(OK) clean"

STRUCTURE_FTL := $(wildcard test/fixtures_structure/*.ftl)
STRUCTURE_AST := $(STRUCTURE_FTL:.ftl=.json)
Expand Down
7 changes: 3 additions & 4 deletions fluent-syntax/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
"email": "[email protected]"
}
],
"directories": {
"lib": "./src"
},
"type": "commonjs",
"main": "./index.js",
"module": "./src/index.js",
"module": "./esm/index.js",
"types": "./esm/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/projectfluent/fluent.js.git"
Expand Down
Loading