@isograph/babel-plugin 0.0.0-main-9fc48513 → 0.0.0-main-4e3f28ae
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/compileTag.js +13 -2
- package/package.json +1 -1
package/compileTag.js
CHANGED
@@ -58,15 +58,26 @@ function compileImportStatement(t, path, type, field, artifactType, config) {
|
|
58
58
|
const filename = path.state.filename;
|
59
59
|
const folder = pathModule.dirname(filename);
|
60
60
|
const cwd = path.state.cwd;
|
61
|
-
const artifactDirectory = pathModule.join(
|
61
|
+
const artifactDirectory = pathModule.join(
|
62
|
+
cwd,
|
63
|
+
config.artifact_directory ?? config.project_root,
|
64
|
+
);
|
62
65
|
|
63
66
|
const fileToArtifactDir = pathModule.relative(folder, artifactDirectory);
|
64
67
|
const artifactDirToArtifact = `/__isograph/${type}/${field}/${artifactType}.ts`;
|
65
|
-
|
68
|
+
let fileToArtifact = pathModule.join(
|
66
69
|
fileToArtifactDir,
|
67
70
|
artifactDirToArtifact,
|
68
71
|
);
|
69
72
|
|
73
|
+
// If we do not have to traverse upward, e.g. if the resolver is in
|
74
|
+
// src/HomePage, and the artifact directory is src/, then fileToArtifact
|
75
|
+
// will start with a /. require('/...') is not good, as that is treated
|
76
|
+
// as an absolute path. Or something. It should instead be './...'.
|
77
|
+
if (fileToArtifact.startsWith('/')) {
|
78
|
+
fileToArtifact = '.' + fileToArtifact;
|
79
|
+
}
|
80
|
+
|
70
81
|
path.replaceWith(
|
71
82
|
t.memberExpression(
|
72
83
|
t.CallExpression(t.Identifier('require'), [
|