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

Do not bundle polyfills with knex #3024

Merged
merged 1 commit into from Jan 31, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion UPGRADING.md
Expand Up @@ -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+

Expand Down
16 changes: 11 additions & 5 deletions knex.js
Expand Up @@ -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).`
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion src/migrate/sources/fs-migrations.js
Expand Up @@ -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',
Expand Down