Skip to content

Commit

Permalink
feat(project-template): add json RequireJS plugin to new projects
Browse files Browse the repository at this point in the history
  • Loading branch information
JeroenVinke committed Apr 6, 2017
1 parent 1d1d501 commit bff36da
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
21 changes: 17 additions & 4 deletions lib/commands/new/project-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ exports.ProjectTemplate = class {
};

this.model = Object.assign({}, model, {
paths: {}
paths: {},
map: {}
});

this.postInstallProcesses = [];
Expand Down Expand Up @@ -56,6 +57,15 @@ exports.ProjectTemplate = class {
this.generators = ProjectItem.directory('generators');
this.environments = ProjectItem.directory('environments');

this.nodeModules = ProjectItem.directory('../node_modules');

this.jsonPlugin = ProjectItem.file('json.js');
this.nodeModules.add(
ProjectItem.directory('../node_modules/requirejs-json').add(
this.jsonPlugin
)
);

this.projectFolder = ProjectItem.directory('aurelia_project').add(
this.tasks,
this.generators,
Expand Down Expand Up @@ -143,7 +153,8 @@ exports.ProjectTemplate = class {
'aurelia-animator-css',
'bluebird',
'requirejs',
'text'
'text',
'requirejs-json'
).addToDevDependencies(
'aurelia-cli',
'aurelia-testing',
Expand Down Expand Up @@ -252,7 +263,8 @@ exports.ProjectTemplate = class {
elements: this.elements.calculateRelativePath(this.src),
attributes: this.attributes.calculateRelativePath(this.src),
valueConverters: this.valueConverters.calculateRelativePath(this.src),
bindingBehaviors: this.bindingBehaviors.calculateRelativePath(this.src)
bindingBehaviors: this.bindingBehaviors.calculateRelativePath(this.src),
json: this.jsonPlugin.calculateRelativePath(this.src).replace('.js', '')
});

this.model.transpiler.source = path.posix.join(appRoot, '**/*' + this.model.transpiler.fileExtension);
Expand Down Expand Up @@ -283,7 +295,8 @@ exports.ProjectTemplate = class {
'configTarget': 'vendor-bundle.js',
'includeBundleMetadataInConfig': 'auto',
'plugins': [
{ 'name': 'text', 'extensions': ['.html', '.css'], 'stub': true }
{ 'name': 'text', 'extensions': ['.html', '.css'], 'stub': true },
{ 'name': 'json', 'extensions': ['.json'], 'stub': true }
]
},
'options': {
Expand Down
4 changes: 3 additions & 1 deletion lib/commands/new/transpilers/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ module.exports = function(project) {
project.addToContent(
ProjectItem.resource('tslint.json', 'content/tslint.json'),
ProjectItem.resource('tsconfig.json', 'content/tsconfig.json'),
ProjectItem.directory('custom_typings')
ProjectItem.directory('custom_typings').add(
ProjectItem.resource('custom_typings.d.ts', 'content/custom_typings.d.ts')
)
).addToTasks(
ProjectItem.resource('transpile.ts', 'tasks/transpile.ts')
).addToDevDependencies(
Expand Down
1 change: 1 addition & 0 deletions lib/dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ let versionMap = {
'karma-typescript-preprocessor': '^0.2.1',
'minimatch': '^3.0.2',
'requirejs': '^2.3.2',
'requirejs-json': '^0.0.3',
'text': 'github:requirejs/text#latest',
'through2': '^2.0.1',
'tslint': '^3.11.0',
Expand Down
9 changes: 9 additions & 0 deletions lib/resources/content/custom_typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
declare module "text!*" {
const value: any;
export default value;
}

declare module "json!*" {
const value: any;
export default value;
}

0 comments on commit bff36da

Please sign in to comment.