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

Rewrite code in ES5 #81

Merged
merged 1 commit into from
Jun 1, 2017
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
13 changes: 0 additions & 13 deletions .babelrc

This file was deleted.

1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
dist/

Gruntfile.js
7 changes: 2 additions & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
{
"extends": "notninja/es6",
"extends": "notninja/es5",
"env": {
"browser": true,
"node": true
},
"parser": "babel-eslint",
"parserOptions": {
"sourceType": "module"
},
"rules": {
"max-params": [
"error",
5
],
"no-bitwise": "off",
"no-invalid-this": "off",
"no-unused-vars": [
"warn",
{
Expand Down
103 changes: 30 additions & 73 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,10 @@
'use strict';

module.exports = function(grunt) {
var babel = require('rollup-plugin-babel');
var commonjs = require('rollup-plugin-commonjs');
var nodeResolve = require('rollup-plugin-node-resolve');
var uglify = require('rollup-plugin-uglify');

var bannerLarge = [
'/*',
' * QRious v<%= pkg.version %>',
' * Copyright (C) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>',
' * Copyright (C) 2010 Tom Zerucha',
' *',
' * This program is free software: you can redistribute it and/or modify',
' * it under the terms of the GNU General Public License as published by',
' * the Free Software Foundation, either version 3 of the License, or',
' * (at your option) any later version.',
' *',
' * This program is distributed in the hope that it will be useful,',
' * but WITHOUT ANY WARRANTY; without even the implied warranty of',
' * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the',
' * GNU General Public License for more details.',
' *',
' * You should have received a copy of the GNU General Public License',
' * along with this program. If not, see <http://www.gnu.org/licenses/>.',
' */'
].join('\n');
var bannerSmall = [
'/*! QRious v<%= pkg.version %> | (C) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %> | GPL v3 License',
'Based on jsqrencode | (C) 2010 tz@execpc.com | GPL v3 License',
'*/'
].join('\n');

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

Expand All @@ -63,55 +36,42 @@ module.exports = function(grunt) {
},

rollup: {
cjs: {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to highlight that the CommonJS distribution file has been removed and is no longer generated by the build since Node.js modules will now import the src/runtime/node.js module directly as it is the new "main" entry in package.json.

options: {
format: 'cjs',
sourceMap: true,
sourceMapRelativePaths: true,
banner: bannerLarge,
external: [ 'canvas' ],
plugins: function() {
return [
nodeResolve({
jsnext: true,
main: true
}),
commonjs(),
babel({
exclude: [ 'node_modules/**' ],
runtimeHelpers: true
})
];
}
},
files: {
'dist/cjs/qrious.js': 'src/runtime/node.js'
}
},
umdDevelopment: {
options: {
format: 'umd',
moduleId: 'qrious',
moduleName: 'QRious',
sourceMap: true,
sourceMapRelativePaths: true,
banner: bannerLarge,
banner: [
'/*',
' * QRious v<%= pkg.version %>',
' * Copyright (C) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>',
' * Copyright (C) 2010 Tom Zerucha',
' *',
' * This program is free software: you can redistribute it and/or modify',
' * it under the terms of the GNU General Public License as published by',
' * the Free Software Foundation, either version 3 of the License, or',
' * (at your option) any later version.',
' *',
' * This program is distributed in the hope that it will be useful,',
' * but WITHOUT ANY WARRANTY; without even the implied warranty of',
' * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the',
' * GNU General Public License for more details.',
' *',
' * You should have received a copy of the GNU General Public License',
' * along with this program. If not, see <http://www.gnu.org/licenses/>.',
' */'
].join('\n'),
plugins: function() {
return [
nodeResolve({
jsnext: true,
main: true
}),
commonjs(),
babel({
exclude: [ 'node_modules/**' ],
runtimeHelpers: true
})
nodeResolve({ main: true }),
commonjs()
];
}
},
files: {
'dist/umd/qrious.js': 'src/runtime/browser.js'
'dist/qrious.js': 'src/runtime/browser.js'
}
},
umdProduction: {
Expand All @@ -121,18 +81,15 @@ module.exports = function(grunt) {
moduleName: 'QRious',
sourceMap: true,
sourceMapRelativePaths: true,
banner: bannerSmall,
banner: [
'/*! QRious v<%= pkg.version %> | (C) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %> | GPL v3 License',
'Based on jsqrencode | (C) 2010 tz@execpc.com | GPL v3 License',
'*/'
].join('\n'),
plugins: function() {
return [
nodeResolve({
jsnext: true,
main: true
}),
nodeResolve({ main: true }),
commonjs(),
babel({
exclude: [ 'node_modules/**' ],
runtimeHelpers: true
}),
uglify({
output: {
comments: function(node, comment) {
Expand All @@ -144,7 +101,7 @@ module.exports = function(grunt) {
}
},
files: {
'dist/umd/qrious.min.js': 'src/runtime/browser.js'
'dist/qrious.min.js': 'src/runtime/browser.js'
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since UMD is now the only distribution format that's generated by the build, I've moved its files to the dist directory directly instead of under the umd sub-directory.

This will be a breaking changed for those using the CDN download links referenced in the README, but I fear that it's best. If I get enough kickback, I might add symbolic links, otherwise, I will recommend that they simply change their URLs as follows for the 2.3.0:

The download links in the README have been updated as part as this PR.

}
}
},
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

[![Chat](https://img.shields.io/gitter/room/neocotic/qrious.svg?style=flat-square)](https://gitter.im/neocotic/qrious)
[![Build Status](https://img.shields.io/travis/neocotic/qrious/develop.svg?style=flat-square)](https://travis-ci.org/neocotic/qrious)
[![Dependency Status](https://img.shields.io/david/neocotic/qrious.svg?style=flat-square)](https://david-dm.org/neocotic/qrious)
[![Optional Dependency Status](https://img.shields.io/david/optional/neocotic/qrious.svg?style=flat-square)](https://david-dm.org/neocotic/qrious?type=optional)
[![Dev Dependency Status](https://img.shields.io/david/dev/neocotic/qrious.svg?style=flat-square)](https://david-dm.org/neocotic/qrious?type=dev)
[![License](https://img.shields.io/npm/l/qrious.svg?style=flat-square)](https://github.com/neocotic/qrious/blob/master/LICENSE.md)
Expand Down Expand Up @@ -38,8 +39,8 @@ you want to install that way instead of using `npm`.

If you want to simply download the file to be used in the browser you can find them below:

* [Development Version](https://cdn.rawgit.com/neocotic/qrious/master/dist/umd/qrious.js) (123kb - [Source Map](https://cdn.rawgit.com/neocotic/qrious/master/dist/umd/qrious.js.map))
* [Production Version](https://cdn.rawgit.com/neocotic/qrious/master/dist/umd/qrious.min.js) (37kb - [Source Map](https://cdn.rawgit.com/neocotic/qrious/master/dist/umd/qrious.min.js.map))
* [Development Version](https://cdn.rawgit.com/neocotic/qrious/master/dist/qrious.js) (123kb - [Source Map](https://cdn.rawgit.com/neocotic/qrious/master/dist/qrious.js.map))
* [Production Version](https://cdn.rawgit.com/neocotic/qrious/master/dist/qrious.min.js) (37kb - [Source Map](https://cdn.rawgit.com/neocotic/qrious/master/dist/qrious.min.js.map))

### Node.js Dependencies

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"type": "git",
"url": "https://github.com/neocotic/qrious.git"
},
"main": "dist/umd/qrious.js",
"main": "dist/qrious.js",
"ignore": [
"src/",
".*",
Expand Down
2 changes: 1 addition & 1 deletion demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
</section>
</main>

<script src="./dist/umd/qrious.js"></script>
<script src="./dist/qrious.js"></script>
<script>
(function() {
var $background = document.querySelector('main form [name="background"]');
Expand Down
Loading