Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// require('../aliases');
// Enables ES2015 import/export in Node.js
require('reify');
const path = require('path');
const moduleAlias = require('module-alias');
moduleAlias.addAlias('probe.gl/test', path.resolve('./dist/test'));
moduleAlias.addAlias('probe.gl/bench', path.resolve('./dist/bench'));
moduleAlias.addAlias('probe.gl', path.resolve('./dist'));
// Run the tests
require('./test-index');
'use strict'
if (typeof require !== 'undefined') {
// 为了兼容 webpack alias 与 DefinePlugin
global.__VERSION_WEB__ = 'v1.0.0'
const moduleAlias = require('module-alias')
moduleAlias.addAlias('core-module', __dirname + '../../../core')
global.window = require('./web-mock')
let BaaS = require('../../sdk-file/src/web')
global.BaaS = BaaS
const sinon = require('sinon')
const sinonStubPromise = require('sinon-stub-promise')
sinonStubPromise(sinon)
global.sinon = sinon
global.expect = require('chai').expect
}
// BaaS 测试环境初始化设置(必须)
BaaS.test = {
clientID: 'ClientID-v233',
}
;(() => {
if (SETUP_DONE) return
// Let's save us from the work ASAP
const [, ...mhyIfStr] = (process.argv.find(a => a.startsWith('--mhy-if')) || '').split('=')
if (mhyIfStr.length && !eval(mhyIfStr.join('='))) {
console.info(`Skipping command due to falsy expression: ${mhyIfStr.join('=')}`)
process.exit(0)
}
// Register dist with alias and mhy's node_modules as module source so custom JS files can use it loaded through mhy
addAlias('@/mhy', path.resolve(__dirname, '../'))
addPath(path.resolve(__dirname, '../../node_modules'))
process.env.NODE_ENV = process.env.NODE_ENV || 'development'
process.env.MHY_ENV = 'cli'
process.env.MHY_ENVS = [process.env.NODE_ENV]
process.env.MHY_LOCAL_DIR = '.mhy'
const envsMap = {
prod: 'production',
dev: 'development'
}
const [, mhyEnvsStr = ''] = (process.argv.find(a => a.startsWith('--mhy-env')) || '').split('=')
const mhyEnvsList = mhyEnvsStr.split(':').filter(a => a)
if (mhyEnvsList.length) {
const NODE_ENV = (mhyEnvsList[0] = envsMap[mhyEnvsList[0]] || mhyEnvsList[0])
process.env.MHY_ENVS = mhyEnvsList
const port = parseInt(process.env.PORT, 10) || 3000
const dev = process.env.NODE_ENV !== 'production'
const moduleAlias = require('module-alias')
const path = require('path')
// For the development version, we'll use React.
// Because, it support react hot loading and so on.
if (!dev) {
moduleAlias.addAlias('react', path.resolve('./lib/inferno-compat.js'))
moduleAlias.addAlias('react-dom/server', 'inferno-server')
moduleAlias.addAlias('react-dom', path.resolve('./lib/inferno-compat.js'))
}
const { createServer } = require('http')
const { parse } = require('url')
const next = require('next')
const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare().then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url, true)
handle(req, res, parsedUrl)
}).listen(port, err => {
const { createServer } = require("http");
const { parse } = require("url");
const { join } = require("path");
const moduleAlias = require("module-alias");
const dev = process.env.NODE_ENV !== "production";
if (!dev) {
moduleAlias.addAlias("react", "preact-compat");
moduleAlias.addAlias("react-dom", "preact-compat");
}
const next = require("next");
const routes = require("./routes");
const app = next({ dev });
const pagesHandler = routes.getRequestHandler(app);
function staticHandler(req, res) {
const parsedUrl = parse(req.url, true);
const rootStaticFiles = ["/service-worker.js"];
if (parsedUrl.pathname === "/favicon.ico") {
const filePath = join(__dirname, "static", parsedUrl.pathname);
app.serveStatic(req, res, filePath);
} else if (rootStaticFiles.includes(parsedUrl.pathname)) {
const filePath = join(__dirname, ".next", parsedUrl.pathname);
const { createServer } = require("http");
const { parse } = require("url");
const { join } = require("path");
const moduleAlias = require("module-alias");
const dev = process.env.NODE_ENV !== "production";
if (!dev) {
moduleAlias.addAlias("react", "preact-compat");
moduleAlias.addAlias("react-dom", "preact-compat");
}
const next = require("next");
const routes = require("./routes");
const app = next({ dev });
const pagesHandler = routes.getRequestHandler(app);
function staticHandler(req, res) {
const parsedUrl = parse(req.url, true);
const rootStaticFiles = ["/service-worker.js"];
if (parsedUrl.pathname === "/favicon.ico") {
const filePath = join(__dirname, "static", parsedUrl.pathname);
app.serveStatic(req, res, filePath);
} else if (rootStaticFiles.includes(parsedUrl.pathname)) {
break;
case 'inferno':
checkPackages([
'react',
'react-dom',
'next',
'inferno',
'inferno-compat',
'inferno-server',
]);
break;
}
if (henri.isProduction) {
if (renderer === 'inferno') {
moduleAlias.addAlias('react', 'inferno-compat');
moduleAlias.addAlias('react-dom/server', 'inferno-server');
moduleAlias.addAlias('react-dom', 'inferno-compat');
}
if (renderer === 'preact') {
moduleAlias.addAlias('react', 'preact-compat');
moduleAlias.addAlias('react-dom', 'preact-compat');
}
}
async function prepare() {
if (henri.isProduction) {
log.info('building next.js pages for production');
try {
await builder(path.resolve(cwd, './app/views'), conf);
} catch (e) {
log.error(e);
'raw-loader',
'cache-loader',
'node-sass',
]);
break;
}
if (this.henri.isProduction) {
if (this.renderer === 'inferno') {
moduleAlias.addAlias('react', 'inferno-compat');
moduleAlias.addAlias('react-dom/server', 'inferno-server');
moduleAlias.addAlias('react-dom', 'inferno-compat');
}
if (this.renderer === 'preact') {
moduleAlias.addAlias('react', 'preact-compat');
moduleAlias.addAlias('react-dom', 'preact-compat');
}
}
}
const path = require('path');
require('module-alias').addAlias('@la', path.join(__dirname, '../src'));