Skip to content

Commit

Permalink
Merge pull request #252 from robwormald/metadata
Browse files Browse the repository at this point in the history
feat(npm): generate AoT files & distribute ES modules + UMD bundle

BREAKING CHANGE: the files are now available as ES modules or UMD bundle and no longer commonjs files

Fixes #218
Fixes #248 
Closes #242
  • Loading branch information
ocombe authored Sep 30, 2016
2 parents dc47974 + ebcf7e8 commit 7d462dc
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 32 deletions.
19 changes: 0 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,6 @@ export class SharedModule {
}
```

##### _Ionic 2 users:_

For Ionic 2 here is a complete bootstrap with configuration. Ionic 2 still uses Angular 2 RC4, which means that you should use ng2-translate version 2.2.2:
```ts
import {TranslateService, TranslateLoader, TranslateStaticLoader} from 'ng2-translate/ng2-translate';

@Component({
templateUrl: '....',
providers: [
{
provide: TranslateLoader,
useFactory: (http: Http) => new TranslateStaticLoader(http, 'assets/i18n', '.json'),
deps: [Http]
},
TranslateService
]
})
```

#### 2. Init the `TranslateService` for your application:

```ts
Expand Down
7 changes: 5 additions & 2 deletions config/webpack.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ module.exports = {
exclude: [
/\.(e2e|spec)\.ts$/,
/node_modules/
]
],
query: {
esModules: true
}
}
]
},
Expand Down Expand Up @@ -100,4 +103,4 @@ module.exports = {
setImmediate: false
}

};
};
2 changes: 1 addition & 1 deletion make.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var config = {
builder.config(config);

builder
.bundle(name, path.resolve(__dirname, 'bundles/', name + '.js'))
.buildStatic(name, path.resolve(__dirname, 'bundles/', name + '.js'), {format: 'umd'})
.then(function() {
console.log('Build complete.');
})
Expand Down
6 changes: 0 additions & 6 deletions ng2-translate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ export * from "./src/translate.pipe";
export * from "./src/translate.service";
export * from "./src/translate.parser";

// for angular-cli
export default {
pipes: [TranslatePipe],
providers: [TranslateService]
};

export function translateLoaderFactory(http: Http) {
return new TranslateStaticLoader(http);
}
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"test": "tsc && karma start",
"test-watch": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"",
"commit": "npm run prepublish && npm test && git-cz",
"prepublish": "tsc && node make.js",
"prepublish": "ngc && node make.js",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
},
"repository": {
Expand All @@ -23,7 +23,8 @@
"bugs": {
"url": "https://github.com/ocombe/ng2-translate/issues"
},
"main": "ng2-translate.js",
"main": "bundles/ng2-translate.js",
"module": "ng2-translate.js",
"typings": "./ng2-translate.d.ts",
"homepage": "https://github.com/ocombe/ng2-translate",
"peerDependencies": {
Expand All @@ -33,6 +34,7 @@
"devDependencies": {
"@angular/common": "2.0.0",
"@angular/compiler": "2.0.0",
"@angular/compiler-cli": "^0.6.3",
"@angular/core": "2.0.0",
"@angular/http": "2.0.0",
"@angular/platform-browser": "2.0.0",
Expand Down
8 changes: 6 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"noImplicitAny": true,
"module": "commonjs",
"module": "es2015",
"target": "es5",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
Expand All @@ -28,5 +28,9 @@
"exclude": [
"node_modules",
"bundles"
]
],
"angularCompilerOptions": {
"strictMetadataEmit": true,
"skipTemplateCodegen": true
}
}

0 comments on commit 7d462dc

Please sign in to comment.