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

Compile with Ivy #78

Merged
merged 11 commits into from
Jan 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"root": true,
"ignorePatterns": ["dist"],
"overrides": [
{
"files": ["*.ts"],
"parserOptions": {
"project": ["./tsconfig.lib.json", "./tsconfig.spec.json"]
},
"extends": [
"plugin:@angular-eslint/recommended",
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"rules": {
"@typescript-eslint/no-explicit-any": "off"
}
},
{
"files": ["*.html"],
"extends": [
"plugin:@angular-eslint/template/recommended",
"plugin:prettier/recommended"
],
"rules": {}
},
{
"files": ["*.json"],
"extends": ["plugin:prettier/recommended"],
"rules": {}
}
]
}
2 changes: 0 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ jobs:
yarn-cache-folder-os-${{ runner.os }}-
- name: Install dependencies
run: yarn install --immutable
- name: Verify code formatting
run: yarn format
- name: Lint
run: yarn lint
- name: Test
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ dist
!.yarn/sdks
!.yarn/versions
.pnp.*

/.angular/cache
546 changes: 546 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

Large diffs are not rendered by default.

768 changes: 768 additions & 0 deletions .yarn/releases/yarn-3.1.0.cjs

Large diffs are not rendered by default.

86 changes: 0 additions & 86 deletions .yarn/releases/yarn-berry.js

This file was deleted.

9 changes: 7 additions & 2 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
yarnPath: ".yarn/releases/yarn-berry.js"
nodeLinker: "node-modules"
nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"

yarnPath: .yarn/releases/yarn-3.1.0.cjs
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [5.0.0] - 2022-01-16
### Removed
- Support for Angular version before v13
- Support for ngx-translate versions before v14

## [4.11.0] - 2021-11-27
### Added
- Support for Angular v13
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ Something to be aware of if you deploy to strict production environments: [Funda

## Setup

This library currently supports Angular versions 6 through 13 and ngx-translate versions 10 through 13. Check the documentation of @ngx-translate/core to know which of its versions to use, depending on your Angular version.

There are test apps that I use to check compatibility (`ng build` and `ng build --prod`, mainly) here:
https://github.com/lephyrus/messageformat-compiler-test-projects
This library currently supports Angular versions 13+ and ngx-translate versions 14+. (You can still use version 4.x, which supports Angular 6-13 and ngx-translate 10-13.) Check the documentation of @ngx-translate/core to know which of its versions to use, depending on your Angular version.

### Integration with ngx-translate

Expand Down
15 changes: 10 additions & 5 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"prefix": "lib",
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"builder": "@angular-devkit/build-angular:ng-packagr",
"options": {
"tsConfig": "tsconfig.lib.json",
"project": "ng-package.json"
Expand All @@ -30,14 +30,19 @@
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"builder": "@angular-eslint/builder:lint",
"options": {
"tsConfig": ["tsconfig.lib.json", "tsconfig.spec.json"],
"exclude": ["**/node_modules/**"]
"lintFilePatterns": [
"./**/*.ts",
"./**/*.html"
]
}
}
}
}
},
"defaultProject": "ngx-translate-messageformat-compiler"
"defaultProject": "ngx-translate-messageformat-compiler",
"cli": {
"defaultCollection": "@angular-eslint/schematics"
}
}
77 changes: 41 additions & 36 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
"name": "ngx-translate-messageformat-compiler",
"version": "4.11.0",
"version": "5.0.0",
"scripts": {
"ng": "ng",
"build": "ng build",
"build:prod": "ng build --prod",
"build:prod": "ng build --configuration production",
"test": "ng test --watch=false",
"test:watch": "ng test",
"lint": "ng lint",
"format": "prettier -l \"./src/**/*.ts\" \"./*.js\"",
"e2e": "ng e2e"
},
"repository": {
Expand All @@ -34,45 +33,51 @@
},
"homepage": "https://github.com/lephyrus/ngx-translate-messageformat-compiler#readme",
"dependencies": {
"tslib": "^1.10.0"
"tslib": "^2.3.1"
},
"peerDependencies": {
"@angular/core": "^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0",
"@ngx-translate/core": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0",
"@angular/core": "^13.0.0",
"@ngx-translate/core": "^14.0.0",
"messageformat": "^2.0.5"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.900.5",
"@angular-devkit/build-ng-packagr": "~0.900.5",
"@angular/cli": "~9.0.5",
"@angular/common": "~9.0.5",
"@angular/compiler": "~9.0.5",
"@angular/compiler-cli": "~9.0.5",
"@angular/core": "~9.0.5",
"@angular/language-service": "~9.0.5",
"@angular/platform-browser": "~9.0.5",
"@angular/platform-browser-dynamic": "~9.0.5",
"@ngx-translate/core": "^11.0.1",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^12.11.1",
"codelyzer": "^5.1.2",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.3.0",
"@angular-devkit/build-angular": "~13.0.3",
"@angular-eslint/builder": "13.0.1",
"@angular-eslint/eslint-plugin": "13.0.1",
"@angular-eslint/eslint-plugin-template": "13.0.1",
"@angular-eslint/schematics": "13.0.1",
"@angular-eslint/template-parser": "13.0.1",
"@angular/cli": "~13.0.3",
"@angular/common": "~13.0.2",
"@angular/compiler": "~13.0.2",
"@angular/compiler-cli": "~13.0.2",
"@angular/core": "~13.0.2",
"@angular/language-service": "~13.0.2",
"@angular/platform-browser": "~13.0.2",
"@angular/platform-browser-dynamic": "~13.0.2",
"@ngx-translate/core": "^14.0.0",
"@types/jasmine": "~3.10.2",
"@types/jasminewd2": "~2.0.10",
"@types/node": "^12.20.37",
"@typescript-eslint/eslint-plugin": "5.4.0",
"@typescript-eslint/parser": "5.4.0",
"eslint": "^8.3.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"jasmine-core": "~3.10.1",
"jasmine-spec-reporter": "~7.0.0",
"karma": "~6.3.9",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"messageformat": "^2.0.5",
"ng-packagr": "^9.0.0",
"prettier": "^2.0.5",
"protractor": "~5.4.3",
"rxjs": "~6.5.4",
"ts-node": "~8.3.0",
"tslint": "~5.18.0",
"karma-coverage-istanbul-reporter": "~3.0.3",
"karma-jasmine": "~4.0.1",
"karma-jasmine-html-reporter": "^1.7.0",
"messageformat": "^2.3.0",
"ng-packagr": "^13.0.8",
"prettier": "^2.5.0",
"protractor": "~7.0.0",
"rxjs": "~6.5.5",
"tslint-config-prettier": "^1.18.0",
"typescript": "~3.7.5",
"zone.js": "~0.10.2"
"typescript": "~4.4.4",
"zone.js": "~0.11.4"
}
}
57 changes: 10 additions & 47 deletions src/lib/translate-message-format-compiler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,7 @@ describe("TranslateMessageFormatCompiler", () => {
"en-US"
)(["a", "\u05d1", "\u05d2"]);
expect(toCharCodes(result)).toEqual([
97,
32,
62,
62,
32,
1489,
32,
62,
62,
32,
1490,
97, 32, 62, 62, 32, 1489, 32, 62, 62, 32, 1490,
]);

// StrictNumberSign
Expand All @@ -49,23 +39,8 @@ describe("TranslateMessageFormatCompiler", () => {
"en"
)(["a", "\u05d1", "\u05d2"]);
expect(toCharCodes(result)).toEqual([
8206,
97,
8206,
32,
62,
62,
32,
8206,
1489,
8206,
32,
62,
62,
32,
8206,
1490,
8206,
8206, 97, 8206, 32, 62, 62, 32, 8206, 1489, 8206, 32, 62, 62, 32, 8206,
1490, 8206,
]);

compiler = new TranslateMessageFormatCompiler({ biDiSupport: false });
Expand All @@ -74,17 +49,7 @@ describe("TranslateMessageFormatCompiler", () => {
"en"
)(["a", "\u05d1", "\u05d2"]);
expect(toCharCodes(result)).toEqual([
97,
32,
62,
62,
32,
1489,
32,
62,
62,
32,
1490,
97, 32, 62, 62, 32, 1489, 32, 62, 62, 32, 1490,
]);
});

Expand Down Expand Up @@ -149,8 +114,8 @@ describe("TranslateMessageFormatCompiler", () => {

it("should respect passed-in formatters", () => {
const formatters = {
locale: (v: any, lc: string) => lc,
prop: (v: { [key: string]: string }, lc: any, p: any) => v[p],
locale: (_v: any, lc: string) => lc,
prop: (v: { [key: string]: string }, _lc: any, p: any) => v[p],
upcase: (v: string) => v.toUpperCase(),
};
const messages = {
Expand Down Expand Up @@ -180,7 +145,7 @@ describe("TranslateMessageFormatCompiler", () => {
try {
compiler.compile(invalidPluralString, "en-GB");
fail("Should throw an exception");
} catch (e) {
} catch (e: any) {
expect(e.message).toContain("Valid plural keys for this locale are");
}

Expand All @@ -190,7 +155,7 @@ describe("TranslateMessageFormatCompiler", () => {
try {
compiler.compile(invalidPluralString, "en-GB");
fail("Should throw an exception");
} catch (e) {
} catch (e: any) {
expect(e.message).toContain("Valid plural keys for this locale are");
}

Expand Down Expand Up @@ -253,10 +218,8 @@ describe("TranslateMessageFormatCompiler", () => {
beforeEach(() => {
translations = {
alpha: {
one:
"{count, plural, =0{No} one{A} other{Several}} {count, plural, one{word} other{words}}",
two:
"{gender, select, male{He is} female{She is} other{They are}} {how}",
one: "{count, plural, =0{No} one{A} other{Several}} {count, plural, one{word} other{words}}",
two: "{gender, select, male{He is} female{She is} other{They are}} {how}",
},
};
});
Expand Down
2 changes: 1 addition & 1 deletion src/lib/translate-message-format-debug-compiler.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TranslateMessageFormatCompiler } from "./translate-message-format-compiler";
import { TranslateMessageFormatDebugCompiler } from "./translate-message-format-debug-compiler";

/* tslint:disable:no-console */
/* eslint-disable no-console */
describe("TranslateMessageFormatDebugCompiler", () => {
let compiler: TranslateMessageFormatCompiler;

Expand Down
2 changes: 1 addition & 1 deletion src/lib/translate-message-format-debug-compiler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from "@angular/core";
import { TranslateMessageFormatCompiler } from "./translate-message-format-compiler";

/* tslint:disable-next-line no-console */
/* eslint-disable-next-line no-console */
const log = (...message: string[]) => console.log(tag, ...message);
const tag = "[TranslateMessageFormatCompiler]";

Expand Down
9 changes: 6 additions & 3 deletions src/test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files

import "zone.js/dist/zone";
import "zone.js/dist/zone-testing";
import "zone.js";
import "zone.js/testing";
import { getTestBed } from "@angular/core/testing";
import {
BrowserDynamicTestingModule,
Expand All @@ -22,7 +22,10 @@ declare const require: {
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
platformBrowserDynamicTesting(),
{
teardown: { destroyAfterEach: false },
}
);
// Then we find all the tests.
const context = require.context("./", true, /\.spec\.ts$/);
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"module": "esnext",
"module": "es2020",
"moduleResolution": "node",
"importHelpers": true,
"strict": true,
Expand Down
1 change: 1 addition & 0 deletions tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/lib",
"declarationMap": true,
"target": "es2015",
"declaration": true,
"inlineSources": true,
Expand Down
5 changes: 4 additions & 1 deletion tsconfig.lib.prod.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"extends": "./tsconfig.lib.json",
"compilerOptions": {
"declarationMap": false
},
"angularCompilerOptions": {
"enableIvy": false
"compilationMode": "partial"
}
}
Loading