Merge pull request #2549 from NativeScript/hdeshev/package-mains

Make package mains more webpack-friendly
This commit is contained in:
Hristo Deshev
2016-08-05 16:29:39 +03:00
committed by GitHub
69 changed files with 92 additions and 78 deletions

View File

@@ -439,24 +439,37 @@ module.exports = function(grunt) {
"copy:childPackageFiles"
]);
grunt.registerTask("check-packagejson-boms", function() {
function hasBOM(filepath) {
var buf = grunt.file.read(filepath, { encoding: null });
return (buf[0] === 0xEF && buf[1] === 0xBB && buf[2] === 0xBF);
}
function validatePackageJsons(fileValidator, errorFormatter) {
var packageDescriptors = grunt.file.expand({}, [
'**/package.json',
'!node_modules/**'
'tns-core-modules/**/package.json'
]);
var errors = packageDescriptors.map(function(packagePath) {
if (hasBOM(packagePath)) {
return "File " + packagePath + " contains a UTF-8 BOM.";
if (fileValidator(packagePath)) {
return errorFormatter(packagePath);
} else {
return null;
}
}).filter(function(errorMessage) { return !!errorMessage; });
if (errors.length > 0)
grunt.fail.fatal("\n" + errors.join("\n"));
}
grunt.registerTask("check-packagejson-boms", function() {
validatePackageJsons(function (filepath) {
var buf = grunt.file.read(filepath, { encoding: null });
return (buf[0] === 0xEF && buf[1] === 0xBB && buf[2] === 0xBF);
}, function(filepath) {
return "File " + filepath + " contains a UTF-8 BOM.";
});
});
grunt.registerTask("check-packagejson-mains", function() {
validatePackageJsons(function (filepath) {
var packageData = grunt.file.readJSON(filepath);
return /\.js/i.test(packageData.main || "");
}, function(filepath) {
return "File " + filepath + " contains a broken main setting.";
});
});
grunt.registerTask("generate-tns-core-modules-dev-dts", generateModulesDts.bind(null, ".", localCfg.srcTnsCoreModules));
@@ -475,6 +488,7 @@ module.exports = function(grunt) {
"clean:build",
"shell:getGitSHA",
"check-packagejson-boms",
"check-packagejson-mains",
"compile-ts",
"collect-modules-raw-files",
"copy:definitionFiles",
@@ -557,4 +571,4 @@ module.exports = function(grunt) {
"pack-apps",
"get-ready-packages"
]));
};
};

View File

@@ -1,5 +1,5 @@
{
"name" : "application-settings",
"main" : "application-settings.js",
"main" : "application-settings",
"nativescript": {}
}

View File

@@ -1,5 +1,5 @@
{
"name" : "application",
"main" : "application.js",
"main" : "application",
"nativescript": {}
}

View File

@@ -1,6 +1,6 @@
{
"name" : "camera",
"main" : "camera.js",
"main" : "camera",
"nativescript": {}
}

View File

@@ -1,6 +1,6 @@
{
"name" : "color",
"main" : "color.js",
"main" : "color",
"nativescript": {}
}

View File

@@ -1,5 +1,5 @@
{
"name" : "connectivity",
"main" : "connectivity.js",
"main" : "connectivity",
"nativescript": {}
}

View File

@@ -1,6 +1,6 @@
{
"name" : "console",
"main" : "console.js",
"main" : "console",
"nativescript": {}
}

View File

@@ -1,4 +1,4 @@
{
"name" : "observable-array",
"main" : "observable-array.js"
"main" : "observable-array"
}

View File

@@ -1,4 +1,4 @@
{
"name" : "observable",
"main" : "observable.js"
"main" : "observable"
}

View File

@@ -1,4 +1,4 @@
{
"name" : "virtual-array",
"main" : "virtual-array.js"
"main" : "virtual-array"
}

View File

@@ -1,5 +1,5 @@
{
"name" : "debugger",
"main" : "debugger.js",
"main" : "debugger",
"nativescript": {}
}

View File

@@ -1,5 +1,5 @@
{
"name" : "fetch",
"main" : "fetch.js",
"main" : "fetch",
"nativescript": {}
}

View File

@@ -1,5 +1,5 @@
{
"name" : "file-system",
"main" : "file-system.js",
"main" : "file-system",
"nativescript": {}
}

View File

@@ -1,6 +1,6 @@
{
"name" : "fps-meter",
"main" : "fps-meter.js",
"main" : "fps-meter",
"nativescript": {}
}

View File

@@ -1,6 +1,6 @@
{
"name" : "globals",
"main" : "globals.js",
"main" : "globals",
"nativescript": {}
}

View File

@@ -1,6 +1,6 @@
{
"name" : "http",
"main" : "http.js",
"main" : "http",
"nativescript": {}
}

View File

@@ -1,6 +1,6 @@
{
"name" : "image-source",
"main" : "image-source.js",
"main" : "image-source",
"nativescript": {}
}

View File

@@ -8,7 +8,7 @@
"pure"
],
"version": "0.1.14",
"main": "easysax.js",
"main": "easysax",
"bugs": {
"url": "https://github.com/vflash/easysax/issues"
},

View File

@@ -2,7 +2,7 @@
"name": "esprima",
"description": "ECMAScript parsing infrastructure for multipurpose analysis",
"homepage": "http://esprima.org",
"main": "esprima.js",
"main": "esprima",
"bin": {
"esparse": "./bin/esparse.js",
"esvalidate": "./bin/esvalidate.js"

View File

@@ -1,2 +1,2 @@
{ "name" : "polymer-expressions",
"main" : "polymer-expressions.js" }
"main" : "polymer-expressions" }

View File

@@ -1,6 +1,6 @@
{
"name" : "location",
"main" : "location.js",
"main" : "location",
"nativescript": {}
}

View File

@@ -1,5 +1,5 @@
{
"name" : "platform",
"main" : "platform.js",
"main" : "platform",
"nativescript": {}
}

View File

@@ -1,5 +1,5 @@
{
"name" : "text",
"main" : "text.js",
"main" : "text",
"nativescript": {}
}

View File

@@ -1,5 +1,5 @@
{
"name" : "timer",
"main" : "timer.js",
"main" : "timer",
"nativescript": {}
}

View File

@@ -1,5 +1,5 @@
{
"name" : "trace",
"main" : "trace.js",
"main" : "trace",
"nativescript": {}
}

View File

@@ -1,2 +1,2 @@
{ "name" : "action-bar",
"main" : "action-bar.js" }
"main" : "action-bar" }

View File

@@ -1,2 +1,2 @@
{ "name" : "activity-indicator",
"main" : "activity-indicator.js" }
"main" : "activity-indicator" }

View File

@@ -1,2 +1,2 @@
{ "name" : "animation",
"main" : "animation.js" }
"main" : "animation" }

View File

@@ -1,2 +1,2 @@
{ "name" : "border",
"main" : "border.js" }
"main" : "border" }

View File

@@ -1,2 +1,2 @@
{ "name" : "builder",
"main" : "builder.js" }
"main" : "builder" }

View File

@@ -1,2 +1,2 @@
{ "name" : "button",
"main" : "button.js" }
"main" : "button" }

View File

@@ -1,2 +1,2 @@
{ "name" : "content-view",
"main" : "content-view.js" }
"main" : "content-view" }

View File

@@ -1,2 +1,2 @@
{ "name" : "date-picker",
"main" : "date-picker.js" }
"main" : "date-picker" }

View File

@@ -1,2 +1,2 @@
{ "name" : "dialogs",
"main" : "dialogs.js" }
"main" : "dialogs" }

View File

@@ -1,2 +1,2 @@
{ "name" : "editable-text-base",
"main" : "editable-text-base.js" }
"main" : "editable-text-base" }

View File

@@ -1,2 +1,2 @@
{ "name" : "enums",
"main" : "enums.js" }
"main" : "enums" }

View File

@@ -1,2 +1,2 @@
{ "name" : "frame",
"main" : "frame.js" }
"main" : "frame" }

View File

@@ -1,2 +1,2 @@
{ "name" : "gestures",
"main" : "gestures.js" }
"main" : "gestures" }

View File

@@ -1,2 +1,2 @@
{ "name" : "html-view",
"main" : "html-view.js" }
"main" : "html-view" }

View File

@@ -1,2 +1,2 @@
{ "name" : "image-cache",
"main" : "image-cache.js" }
"main" : "image-cache" }

View File

@@ -1,2 +1,2 @@
{ "name" : "image",
"main" : "image.js" }
"main" : "image" }

View File

@@ -1,2 +1,2 @@
{ "name" : "label",
"main" : "label.js" }
"main" : "label" }

View File

@@ -1,2 +1,2 @@
{ "name" : "absolute-layout",
"main" : "absolute-layout.js" }
"main" : "absolute-layout" }

View File

@@ -1,2 +1,2 @@
{ "name" : "dock-layout",
"main" : "dock-layout.js" }
"main" : "dock-layout" }

View File

@@ -1,2 +1,2 @@
{ "name" : "grid-layout",
"main" : "grid-layout.js" }
"main" : "grid-layout" }

View File

@@ -1,2 +1,2 @@
{ "name" : "stack-layout",
"main" : "stack-layout.js" }
"main" : "stack-layout" }

View File

@@ -1,2 +1,2 @@
{ "name" : "wrap-layout",
"main" : "wrap-layout.js" }
"main" : "wrap-layout" }

View File

@@ -1,2 +1,2 @@
{ "name" : "list-picker",
"main" : "list-picker.js" }
"main" : "list-picker" }

View File

@@ -1,2 +1,2 @@
{ "name" : "list-view",
"main" : "list-view.js" }
"main" : "list-view" }

View File

@@ -1,2 +1,2 @@
{ "name" : "page",
"main" : "page.js" }
"main" : "page" }

View File

@@ -1,2 +1,2 @@
{ "name" : "placeholder",
"main" : "placeholder.js" }
"main" : "placeholder" }

View File

@@ -1,2 +1,2 @@
{ "name" : "progress",
"main" : "progress.js" }
"main" : "progress" }

View File

@@ -1,2 +1,2 @@
{ "name" : "proxy-view-container",
"main" : "proxy-view-container.js" }
"main" : "proxy-view-container" }

View File

@@ -1,2 +1,2 @@
{ "name" : "repeater",
"main" : "repeater.js" }
"main" : "repeater" }

View File

@@ -1,2 +1,2 @@
{ "name" : "scroll-view",
"main" : "scroll-view.js" }
"main" : "scroll-view" }

View File

@@ -1,2 +1,2 @@
{ "name" : "search-bar",
"main" : "search-bar.js" }
"main" : "search-bar" }

View File

@@ -1,2 +1,2 @@
{ "name" : "segmented-bar",
"main" : "segmented-bar.js" }
"main" : "segmented-bar" }

View File

@@ -1,2 +1,2 @@
{ "name" : "slider",
"main" : "slider.js" }
"main" : "slider" }

View File

@@ -1,2 +1,2 @@
{ "name" : "styling",
"main" : "styling.js" }
"main" : "styling" }

View File

@@ -1,2 +1,2 @@
{ "name" : "switch",
"main" : "switch.js" }
"main" : "switch" }

View File

@@ -1,2 +1,2 @@
{ "name" : "ui/tab-view",
"main" : "tab-view.js" }
"main" : "tab-view" }

View File

@@ -1,2 +1,2 @@
{ "name" : "text-base",
"main" : "text-base.js" }
"main" : "text-base" }

View File

@@ -1,2 +1,2 @@
{ "name" : "text-field",
"main" : "text-field.js" }
"main" : "text-field" }

View File

@@ -1,2 +1,2 @@
{ "name" : "text-view",
"main" : "text-view.js" }
"main" : "text-view" }

View File

@@ -1,2 +1,2 @@
{ "name" : "time-picker",
"main" : "time-picker.js" }
"main" : "time-picker" }

View File

@@ -1,2 +1,2 @@
{ "name" : "transition",
"main" : "transition.js" }
"main" : "transition" }

View File

@@ -1,2 +1,2 @@
{ "name" : "web-view",
"main" : "web-view.js" }
"main" : "web-view" }

View File

@@ -1,5 +1,5 @@
{
"name" : "xhr",
"main" : "xhr.js",
"main" : "xhr",
"nativescript": {}
}

View File

@@ -1,5 +1,5 @@
{
"name" : "xml",
"main" : "xml.js",
"main" : "xml",
"nativescript": {}
}