@shopify/react-server
Version:
Utilities for React server-side rendering
40 lines (33 loc) • 1.02 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var fs = require('fs');
var path = require('path');
exports.Entrypoint = void 0;
(function (Entrypoint) {
Entrypoint["Client"] = "client";
Entrypoint["Server"] = "server";
Entrypoint["Error"] = "error";
})(exports.Entrypoint || (exports.Entrypoint = {}));
const HEADER = `
// Generated by @shopify/react-server/webpack-plugin
`;
function noSourceExists(entry, options, {
options: {
context = ''
}
}) {
const {
basePath: path$1
} = options;
const basePath = path.resolve(context, path$1);
// if there is a folder we assume it has an index file
if (fs.existsSync(path.join(basePath, entry))) {
return false;
}
// otherwise we look for explicit files in the folder
const dirFiles = fs.readdirSync(basePath);
const filenameRegex = new RegExp(`^${entry}.[jt]sx?$`);
return dirFiles.find(file => filenameRegex.test(file)) == null;
}
exports.HEADER = HEADER;
exports.noSourceExists = noSourceExists;