From ca28884db226f8090077d7730b3b1cc2fa3a5458 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Thu, 27 Oct 2016 22:54:10 +0200 Subject: [PATCH] Use babel to compile babel-loader move lib to src and have lib the destination of babel --- .babelrc | 5 +++++ .gitignore | 1 + .jscsrc | 1 + .jshintignore | 1 + .jshintrc | 2 +- .travis.yml | 10 ++-------- package.json | 14 +++++++++----- {lib => src}/fs-cache.js | 2 -- {lib => src}/helpers/exists.js | 2 -- {lib => src}/helpers/read.js | 2 -- index.js => src/index.js | 12 +++++------- {lib => src}/resolve-rc.js | 2 -- 12 files changed, 25 insertions(+), 29 deletions(-) create mode 100644 .babelrc rename {lib => src}/fs-cache.js (99%) rename {lib => src}/helpers/exists.js (96%) rename {lib => src}/helpers/read.js (97%) rename index.js => src/index.js (93%) rename {lib => src}/resolve-rc.js (98%) diff --git a/.babelrc b/.babelrc new file mode 100644 index 00000000..67c1a8a7 --- /dev/null +++ b/.babelrc @@ -0,0 +1,5 @@ +{ + "presets": [ + ["latest", { "es2015": { "loose": true } }] + ] +} diff --git a/.gitignore b/.gitignore index 96be86c0..d1407bc4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +lib node_modules test/output coverage diff --git a/.jscsrc b/.jscsrc index e8173c24..abd5a2f1 100644 --- a/.jscsrc +++ b/.jscsrc @@ -2,6 +2,7 @@ "preset": "node-style-guide", "fileExtensions": [ ".js", "jscs" ], "excludeFiles": [ + "lib/**", "test/fixtures/**", "test/output/**", "node_modules/**" diff --git a/.jshintignore b/.jshintignore index c3f74349..c40144ec 100644 --- a/.jshintignore +++ b/.jshintignore @@ -1,2 +1,3 @@ +lib test/fixtures test/output diff --git a/.jshintrc b/.jshintrc index a7002e11..914932a6 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,5 +1,5 @@ { - "strict": true, + "strict": false, "node": true, "mocha": true } diff --git a/.travis.yml b/.travis.yml index 54667443..0d801ddc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,20 +1,14 @@ sudo: false language: node_js -os: - - linux - - osx node_js: - - node - "6" - "5" - "4" + - "0.12" + - "0.10" env: - export WEBPACK_VERSION="2.1.0-beta.22" - export WEBPACK_VERSION="1" -matrix: - fast_finish: true - allow_failures: - - os: osx before_install: - nvm --version - node --version diff --git a/package.json b/package.json index 8fcbfc6d..56bd7ed4 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,9 @@ "version": "6.2.7", "description": "babel module loader for webpack", "files": [ - "index.js", "lib" ], + "main": "lib/index.js", "dependencies": { "find-cache-dir": "^0.1.1", "loader-utils": "^0.2.11", @@ -17,7 +17,9 @@ "webpack": "1 || ^2.1.0-beta" }, "devDependencies": { + "babel-cli": "^6.18.0", "babel-core": "^6.0.0", + "babel-preset-latest": "^6.16.0", "babel-preset-es2015": "^6.0.0", "expect.js": "^0.3.1", "istanbul": "^0.4.0", @@ -27,12 +29,14 @@ "rimraf": "^2.4.3" }, "scripts": { - "test": "npm run hint && npm run cs && npm run cover", - "travis": "npm run cover -- --report lcovonly", + "build": "babel src/ --out-dir lib/", + "test": "npm run build && npm run hint && npm run cs && npm run cover", + "travis": "npm run build && npm run cover -- --report lcovonly", "cover": "istanbul cover ./node_modules/.bin/_mocha -- test/*.test.js", "postcover": "npm run hint && npm run cs", - "hint": "jshint --config .jshintrc index.js lib/* test/*", - "cs": "jscs --config .jscsrc index.js lib/* test/*" + "prepublish": "npm run build", + "hint": "jshint --config .jshintrc src/* test/*", + "cs": "jscs --config .jscsrc src/* test/*" }, "repository": { "type": "git", diff --git a/lib/fs-cache.js b/src/fs-cache.js similarity index 99% rename from lib/fs-cache.js rename to src/fs-cache.js index a2d31f2b..ba7a9bc0 100644 --- a/lib/fs-cache.js +++ b/src/fs-cache.js @@ -1,5 +1,3 @@ -'use strict'; - /** * Filesystem cache * diff --git a/lib/helpers/exists.js b/src/helpers/exists.js similarity index 96% rename from lib/helpers/exists.js rename to src/helpers/exists.js index 35e08ba5..2b9559c3 100644 --- a/lib/helpers/exists.js +++ b/src/helpers/exists.js @@ -1,5 +1,3 @@ -'use strict'; - var fs = require('fs'); /** * Check if file exists and cache the result diff --git a/lib/helpers/read.js b/src/helpers/read.js similarity index 97% rename from lib/helpers/read.js rename to src/helpers/read.js index 6de7e5cd..a52a5878 100644 --- a/lib/helpers/read.js +++ b/src/helpers/read.js @@ -1,5 +1,3 @@ -'use strict'; - var fs = require('fs'); /** * Read the file and cache the result diff --git a/index.js b/src/index.js similarity index 93% rename from index.js rename to src/index.js index e80ce180..b25b8b47 100644 --- a/index.js +++ b/src/index.js @@ -1,14 +1,12 @@ -'use strict'; - var assign = require('object-assign'); var babel = require('babel-core'); var loaderUtils = require('loader-utils'); -var cache = require('./lib/fs-cache.js'); -var exists = require('./lib/helpers/exists')(); -var read = require('./lib/helpers/read')(); -var resolveRc = require('./lib/resolve-rc.js'); -var pkg = require('./package.json'); var path = require('path'); +var cache = require('./fs-cache.js'); +var exists = require('./helpers/exists')(); +var read = require('./helpers/read')(); +var resolveRc = require('./resolve-rc.js'); +var pkg = require('./../package.json'); /** * Error thrown by Babel formatted to conform to Webpack reporting. diff --git a/lib/resolve-rc.js b/src/resolve-rc.js similarity index 98% rename from lib/resolve-rc.js rename to src/resolve-rc.js index b1ac2207..a4644da0 100644 --- a/lib/resolve-rc.js +++ b/src/resolve-rc.js @@ -1,5 +1,3 @@ -'use strict'; - /** * The purpose of this module, is to find the project's .babelrc and * use its contents to bust the babel-loader's internal cache whenever an option