work around canvas/sharp order requirments
This commit is contained in:
parent
44fa77a79d
commit
a3e68c7698
3 changed files with 18 additions and 2 deletions
7
src/render_import_unix.js
Normal file
7
src/render_import_unix.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
// sharp has to be required before node-canvas on linux. see https://github.com/lovell/sharp/issues/371
|
||||
import sharp from 'sharp';
|
||||
import { createCanvas, Image } from 'canvas';
|
||||
|
||||
export {sharp, createCanvas, Image};
|
||||
7
src/render_import_windows.js
Normal file
7
src/render_import_windows.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
// sharp has to be required after node-canvas on windows. see https://github.com/Automattic/node-canvas/issues/2155#issuecomment-1487190125
|
||||
import { createCanvas, Image } from 'canvas';
|
||||
import sharp from 'sharp';
|
||||
|
||||
export {sharp, createCanvas, Image};
|
||||
|
|
@ -6,8 +6,6 @@ import path from 'path';
|
|||
import url from 'url';
|
||||
import util from 'util';
|
||||
import zlib from 'zlib';
|
||||
import sharp from 'sharp'; // sharp has to be required before node-canvas. see https://github.com/lovell/sharp/issues/371
|
||||
import { createCanvas, Image } from 'canvas';
|
||||
import clone from 'clone';
|
||||
import Color from 'color';
|
||||
import express from 'express';
|
||||
|
|
@ -20,6 +18,10 @@ import proj4 from 'proj4';
|
|||
import request from 'request';
|
||||
import { getFontsPbf, getTileUrls, fixTileJSONCenter } from './utils.js';
|
||||
|
||||
import Os from 'os'
|
||||
var ostype = (Os.platform() == 'win32') ? "windows":"unix";
|
||||
const { sharp, createCanvas, Image } = await import(`./render_import_${ostype}.js`);
|
||||
|
||||
const FLOAT_PATTERN = '[+-]?(?:\\d+|\\d+.?\\d+)';
|
||||
const PATH_PATTERN =
|
||||
/^((fill|stroke|width)\:[^\|]+\|)*((enc:.+)|((-?\d+\.?\d*,-?\d+\.?\d*\|)+(-?\d+\.?\d*,-?\d+\.?\d*)))/;
|
||||
|
|
|
|||
Loading…
Reference in a new issue