@graphcommerce/next-config 9.0.4-canary.0 → 9.0.4-canary.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -8
- package/__tests__/commands/copyFiles.ts +8 -5
- package/__tests__/config/utils/__snapshots__/mergeEnvIntoConfig.ts.snap +0 -905
- package/__tests__/config/utils/mergeEnvIntoConfig.ts +21 -3
- package/__tests__/config/utils/replaceConfigInString.ts +0 -1
- package/__tests__/interceptors/findPlugins.ts +270 -272
- package/__tests__/interceptors/generateInterceptors.ts +1 -0
- package/__tests__/utils/resolveDependenciesSync.ts +45 -44
- package/dist/generated/config.js +110 -116
- package/dist/index.js +3359 -26
- package/package.json +34 -8
- package/src/commands/codegen.ts +3 -3
- package/src/commands/copyFiles.ts +14 -7
- package/src/config/commands/generateConfig.ts +17 -6
- package/src/config/demoConfig.ts +0 -1
- package/src/config/loadConfig.ts +3 -9
- package/src/config/utils/mergeEnvIntoConfig.ts +9 -9
- package/src/generated/config.ts +305 -245
- package/src/interceptors/Visitor.ts +1 -1
- package/src/interceptors/findOriginalSource.ts +1 -1
- package/src/interceptors/generateInterceptor.ts +0 -2
- package/src/interceptors/parseStructure.ts +3 -3
- package/src/interceptors/writeInterceptors.ts +1 -1
- package/src/utils/resolveDependenciesSync.ts +44 -7
- package/src/withGraphCommerce.ts +30 -42
- package/tsconfig.json +1 -1
- package/__tests__/config/utils/rewriteLegancyEnv.ts +0 -78
- package/dist/commands/codegen.js +0 -18
- package/dist/commands/copyFiles.js +0 -292
- package/dist/config/commands/exportConfig.js +0 -16
- package/dist/config/commands/generateConfig.js +0 -57
- package/dist/config/demoConfig.js +0 -52
- package/dist/config/index.js +0 -19
- package/dist/config/loadConfig.js +0 -62
- package/dist/config/utils/configToImportMeta.js +0 -39
- package/dist/config/utils/diff.js +0 -33
- package/dist/config/utils/exportConfigToEnv.js +0 -31
- package/dist/config/utils/mergeEnvIntoConfig.js +0 -184
- package/dist/config/utils/replaceConfigInString.js +0 -12
- package/dist/config/utils/rewriteLegacyEnv.js +0 -115
- package/dist/interceptors/InterceptorPlugin.js +0 -108
- package/dist/interceptors/RenameVisitor.js +0 -19
- package/dist/interceptors/Visitor.js +0 -1414
- package/dist/interceptors/commands/codegenInterceptors.js +0 -22
- package/dist/interceptors/extractExports.js +0 -159
- package/dist/interceptors/findOriginalSource.js +0 -103
- package/dist/interceptors/findPlugins.js +0 -68
- package/dist/interceptors/generateInterceptor.js +0 -219
- package/dist/interceptors/generateInterceptors.js +0 -56
- package/dist/interceptors/parseStructure.js +0 -84
- package/dist/interceptors/swc.js +0 -15
- package/dist/interceptors/writeInterceptors.js +0 -44
- package/dist/utils/PackagesSort.js +0 -7
- package/dist/utils/TopologicalSort.js +0 -87
- package/dist/utils/isMonorepo.js +0 -47
- package/dist/utils/packageRoots.js +0 -31
- package/dist/utils/resolveDependenciesSync.js +0 -78
- package/dist/utils/resolveDependency.js +0 -70
- package/dist/utils/sig.js +0 -34
- package/dist/withGraphCommerce.js +0 -162
- package/src/config/utils/rewriteLegacyEnv.ts +0 -125
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.InterceptorPlugin = void 0;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const resolveDependency_1 = require("../utils/resolveDependency");
|
|
9
|
-
const findPlugins_1 = require("./findPlugins");
|
|
10
|
-
const generateInterceptors_1 = require("./generateInterceptors");
|
|
11
|
-
const writeInterceptors_1 = require("./writeInterceptors");
|
|
12
|
-
let interceptors;
|
|
13
|
-
let interceptorByDepependency;
|
|
14
|
-
let generating = false;
|
|
15
|
-
// let totalGenerationTime = 0
|
|
16
|
-
class InterceptorPlugin {
|
|
17
|
-
config;
|
|
18
|
-
regenerate;
|
|
19
|
-
resolveDependency;
|
|
20
|
-
constructor(config, regenerate = false) {
|
|
21
|
-
this.config = config;
|
|
22
|
-
this.regenerate = regenerate;
|
|
23
|
-
this.resolveDependency = (0, resolveDependency_1.resolveDependency)();
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
25
|
-
if (regenerate)
|
|
26
|
-
this.#generateInterceptors();
|
|
27
|
-
}
|
|
28
|
-
#generateInterceptors = async () => {
|
|
29
|
-
if (generating)
|
|
30
|
-
return {};
|
|
31
|
-
generating = true;
|
|
32
|
-
// const start = Date.now()
|
|
33
|
-
// console.log('Generating interceptors...')
|
|
34
|
-
const [plugins] = (0, findPlugins_1.findPlugins)(this.config);
|
|
35
|
-
// console.log(errors)
|
|
36
|
-
// const found = Date.now()
|
|
37
|
-
// console.log('Found plugins in', found - start, 'ms')
|
|
38
|
-
const generatedInterceptors = await (0, generateInterceptors_1.generateInterceptors)(plugins, this.resolveDependency, this.config.debug);
|
|
39
|
-
// const generated = Date.now()
|
|
40
|
-
// console.log('Generated interceptors in', generated - found, 'ms')
|
|
41
|
-
await (0, writeInterceptors_1.writeInterceptors)(generatedInterceptors);
|
|
42
|
-
// const wrote = Date.now()
|
|
43
|
-
// console.log('Wrote interceptors in', wrote - generated, 'ms')
|
|
44
|
-
interceptors = generatedInterceptors;
|
|
45
|
-
interceptorByDepependency = Object.fromEntries(Object.values(interceptors).map((i) => [i.dependency, i]));
|
|
46
|
-
// totalGenerationTime += Date.now() - start
|
|
47
|
-
generating = false;
|
|
48
|
-
return generatedInterceptors;
|
|
49
|
-
};
|
|
50
|
-
/** @public */
|
|
51
|
-
apply(compiler) {
|
|
52
|
-
const logger = compiler.getInfrastructureLogger('InterceptorPlugin');
|
|
53
|
-
// After the compilation has succeeded we watch all possible plugin locations.
|
|
54
|
-
if (this.regenerate) {
|
|
55
|
-
compiler.hooks.afterCompile.tap('InterceptorPlugin', (compilation) => {
|
|
56
|
-
// console.log('generate interceptors after compile')
|
|
57
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
58
|
-
const [plugins, errors] = (0, findPlugins_1.findPlugins)(this.config);
|
|
59
|
-
plugins.forEach((p) => {
|
|
60
|
-
const source = this.resolveDependency(p.sourceModule);
|
|
61
|
-
if (source) {
|
|
62
|
-
const absoluteFilePath = `${path_1.default.join(process.cwd(), source.fromRoot)}.tsx`;
|
|
63
|
-
compilation.fileDependencies.add(absoluteFilePath);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
67
|
-
this.#generateInterceptors().then((i) => {
|
|
68
|
-
Object.entries(i).forEach(([, { sourcePath }]) => {
|
|
69
|
-
const absoluteFilePath = path_1.default.join(process.cwd(), sourcePath);
|
|
70
|
-
compilation.fileDependencies.add(absoluteFilePath);
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
compiler.hooks.normalModuleFactory.tap('InterceptorPlugin', (nmf) => {
|
|
76
|
-
nmf.hooks.beforeResolve.tap('InterceptorPlugin', (resource) => {
|
|
77
|
-
const issuer = resource.contextInfo.issuer ?? '';
|
|
78
|
-
const requestPath = path_1.default.relative(process.cwd(), path_1.default.resolve(resource.context, resource.request));
|
|
79
|
-
if (!interceptors || !interceptorByDepependency) {
|
|
80
|
-
// console.log('interceptors not ready')
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
const split = requestPath.split('/');
|
|
84
|
-
const targets = [
|
|
85
|
-
`${split[split.length - 1]}.interceptor.tsx`,
|
|
86
|
-
`${split[split.length - 1]}.interceptor.ts`,
|
|
87
|
-
];
|
|
88
|
-
if (targets.some((target) => issuer.endsWith(target)) && interceptors[requestPath]) {
|
|
89
|
-
logger.log(`Interceptor ${issuer} is requesting the original ${requestPath}`);
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
const interceptorForRequest = interceptorByDepependency[resource.request];
|
|
93
|
-
if (interceptorForRequest) {
|
|
94
|
-
const extension = interceptorForRequest.sourcePath.endsWith('.tsx') ? '.tsx' : '.ts';
|
|
95
|
-
resource.request = `${interceptorForRequest.denormalized}.interceptor${extension}`;
|
|
96
|
-
logger.log(`Intercepting dep... ${interceptorForRequest.dependency}`, resource.request);
|
|
97
|
-
}
|
|
98
|
-
const interceptorForPath = interceptors[requestPath];
|
|
99
|
-
if (interceptorForPath) {
|
|
100
|
-
const extension = interceptorForPath.sourcePath.endsWith('.tsx') ? '.tsx' : '.ts';
|
|
101
|
-
resource.request = `${resource.request}.interceptor${extension}`;
|
|
102
|
-
logger.log(`Intercepting fromRoot... ${interceptorForPath.dependency}`, resource.request);
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
exports.InterceptorPlugin = InterceptorPlugin;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RenameVisitor = void 0;
|
|
4
|
-
const Visitor_1 = require("./Visitor");
|
|
5
|
-
class RenameVisitor extends Visitor_1.Visitor {
|
|
6
|
-
replace;
|
|
7
|
-
suffix;
|
|
8
|
-
constructor(replace, suffix) {
|
|
9
|
-
super();
|
|
10
|
-
this.replace = replace;
|
|
11
|
-
this.suffix = suffix;
|
|
12
|
-
}
|
|
13
|
-
visitIdentifier(n) {
|
|
14
|
-
if (this.replace.includes(n.value))
|
|
15
|
-
n.value = this.suffix(n.value);
|
|
16
|
-
return n;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.RenameVisitor = RenameVisitor;
|