Do not bundle polyfills with knex (#3024)

This commit is contained in:
Igor Savin 2019-01-31 13:54:29 +01:00 committed by GitHub
parent e7c674e4dd
commit 15ac75cda0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 8 deletions

View File

@ -4,7 +4,8 @@
* MSSQL: DB versions older than 2008 are no longer supported, make sure to update your DB;
* PostgreSQL|MySQL: it is recommended to use options object for `table.datetime` and `table.timestamp` methods instead of argument options. See documentation for these methods for more details;
* Node 6: There are known issues with duplicate event listeners when using knex.js with Node 6 (resulting in MaxListenersExceededWarning under certain use-cases (such as reusing single knex instance to run migrations or seeds multiple times)). Please upgrade to Node 8+ as soon as possible (knex 0.17.0 will be dropping Node 6 support altogether).
* Node 6: There are known issues with duplicate event listeners when using knex.js with Node.js 6 (resulting in MaxListenersExceededWarning under certain use-cases (such as reusing single knex instance to run migrations or seeds multiple times)). Please upgrade to Node.js 8+ as soon as possible (knex 0.17.0 will be dropping Node.js 6 support altogether);
* Node 6: Please add '@babel/polyfill' production dependency to the project when using Node.js 6 (it will be loaded by knex automatically).
### Upgrading to version 0.15.0+

16
knex.js
View File

@ -9,13 +9,19 @@ const { isNode6 } = require('./lib/util/version-helper');
// Should be safe to remove after support for Node.js 6 is dropped
if (isNode6()) {
const oldPromise = global.Promise;
try {
const oldPromise = global.Promise;
require('@babel/polyfill');
require('@babel/polyfill');
// Preserve any Promise overrides set globally prior to importing knex
if (oldPromise) {
global.Promise = oldPromise;
// Preserve any Promise overrides set globally prior to importing knex
if (oldPromise) {
global.Promise = oldPromise;
}
} catch (e) {
throw new Error(
`You are using Node.js 6. Please consider upgrading to Node.js 8+ or add '@babel/polyfill' dependency to the project (knex will automatically load it).`
);
}
}

View File

@ -8,7 +8,6 @@
"node": ">=6"
},
"dependencies": {
"@babel/polyfill": "^7.2.5",
"@types/bluebird": "^3.5.25",
"bluebird": "^3.5.3",
"colorette": "1.0.7",
@ -35,6 +34,7 @@
"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.2.2",
"@babel/polyfill": "^7.2.5",
"@babel/preset-env": "^7.3.1",
"@types/node": "*",
"JSONStream": "^1.3.5",

View File

@ -3,7 +3,8 @@ import path from 'path';
import Promise from 'bluebird';
import { sortBy, filter } from 'lodash';
const readDirAsync = (path) => Promise.promisify(fs.readdir, { context: fs })(path);
const readDirAsync = (path) =>
Promise.promisify(fs.readdir, { context: fs })(path);
export const DEFAULT_LOAD_EXTENSIONS = Object.freeze([
'.co',