tungsten 0.2.6 → 0.2.8
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/dist/Components.d.ts +3 -1
- package/dist/Components.d.ts.map +1 -1
- package/dist/Components.js +100 -51
- package/dist/DomNodes.js +2 -2
- package/dist/FrameworkConfig.d.ts +2 -0
- package/dist/FrameworkConfig.d.ts.map +1 -1
- package/dist/FunctionComponentStandIn.d.ts +2 -0
- package/dist/FunctionComponentStandIn.d.ts.map +1 -1
- package/dist/FunctionComponentStandIn.js +16 -3
- package/dist/Instance/ClientRuntimeContext.d.ts +8 -0
- package/dist/Instance/ClientRuntimeContext.d.ts.map +1 -0
- package/dist/Instance/ClientRuntimeContext.js +1 -0
- package/dist/Instance/Instance.d.ts +20 -1
- package/dist/Instance/Instance.d.ts.map +1 -1
- package/dist/Instance/Instance.js +59 -11
- package/dist/Servers/loadEnvsDev.d.ts +1 -1
- package/dist/Servers/loadEnvsDev.d.ts.map +1 -1
- package/dist/Servers/loadEnvsDev.js +18 -3
- package/dist/Store/makeStore.d.ts.map +1 -1
- package/dist/Store/makeStore.js +7 -14
- package/dist/babelPlugins/BabelTransformPackageImports.d.ts +2 -0
- package/dist/babelPlugins/BabelTransformPackageImports.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTransformPackageImports.js +111 -72
- package/dist/bin/commands/compile.d.ts.map +1 -1
- package/dist/bin/commands/compile.js +87 -13
- package/dist/bin/commands/compile.sxyt.d.ts +2 -0
- package/dist/bin/commands/compile.sxyt.d.ts.map +1 -0
- package/dist/bin/commands/compile.sxyt.js +136 -0
- package/dist/build/compileJavascript.d.ts +11 -1
- package/dist/build/compileJavascript.d.ts.map +1 -1
- package/dist/build/compileJavascript.js +89 -31
- package/dist/build/createClientFiles.d.ts +1 -1
- package/dist/build/createClientFiles.d.ts.map +1 -1
- package/dist/build/createClientFiles.js +7 -7
- package/dist/build/createInstanceConfigFile.d.ts +1 -1
- package/dist/build/createInstanceConfigFile.d.ts.map +1 -1
- package/dist/build/createInstanceConfigFile.js +3 -3
- package/dist/build/makeBabelUserDevConfig.d.ts +1 -1
- package/dist/build/makeBabelUserDevConfig.d.ts.map +1 -1
- package/dist/build/makeBabelUserDevConfig.js +3 -1
- package/dist/findUserConfig.d.ts +1 -1
- package/dist/findUserConfig.d.ts.map +1 -1
- package/dist/findUserConfig.js +2 -2
- package/dist/frameworkConfigSchema.d.ts +4 -0
- package/dist/frameworkConfigSchema.d.ts.map +1 -1
- package/dist/frameworkConfigSchema.js +1 -0
- package/dist/getUserConfig.d.ts +1 -1
- package/dist/getUserConfig.d.ts.map +1 -1
- package/dist/getUserConfig.js +2 -2
- package/dist/hooks/useState.js +1 -1
- package/dist/indexInner.d.ts +0 -1
- package/dist/indexInner.d.ts.map +1 -1
- package/dist/indexInner.js +1 -1
- package/dist/postcssPlugins/parseSelectorsRich.sxyt.js +5 -2
- package/dist/testing/createTestApp.sxyt.d.ts +2 -0
- package/dist/testing/createTestApp.sxyt.d.ts.map +1 -0
- package/dist/testing/createTestApp.sxyt.js +424 -0
- package/dist/testing/ensureTestEnvLoaded.d.ts +2 -0
- package/dist/testing/ensureTestEnvLoaded.d.ts.map +1 -0
- package/dist/testing/ensureTestEnvLoaded.js +19 -0
- package/dist/testing/index.d.ts +36 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +156 -0
- package/dist/update/UpdateScheduler.d.ts +17 -0
- package/dist/update/UpdateScheduler.d.ts.map +1 -0
- package/dist/update/UpdateScheduler.js +113 -0
- package/dist/update/integrateUpdateVdom.d.ts +11 -1
- package/dist/update/integrateUpdateVdom.d.ts.map +1 -1
- package/dist/update/integrateUpdateVdom.js +117 -59
- package/dist/{react-zone.d.ts → zones/react.d.ts} +5 -5
- package/dist/zones/react.d.ts.map +1 -0
- package/dist/{react-zone.js → zones/react.js} +3 -3
- package/package.json +4 -2
- package/readme.md +102 -1
- package/dist/react-zone.d.ts.map +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { join } from 'path';
|
|
1
|
+
import { dirname, join, resolve } from 'path';
|
|
2
|
+
import { promises as fsPromises } from 'fs';
|
|
2
3
|
import rmfr from 'rmfr';
|
|
3
4
|
import { compileJavascript } from "../../build/compileJavascript.js";
|
|
4
5
|
import { compileStyles } from "../../build/compileStyles.js";
|
|
@@ -17,19 +18,38 @@ const targetOptions = {
|
|
|
17
18
|
'--public': 'public'
|
|
18
19
|
};
|
|
19
20
|
const args = process.argv.slice(3);
|
|
21
|
+
function optionValue(option) {
|
|
22
|
+
const position = args.indexOf(option);
|
|
23
|
+
if (position === -1) return undefined;
|
|
24
|
+
const value = args[position + 1];
|
|
25
|
+
if (value === undefined || value.startsWith('--')) {
|
|
26
|
+
cliError(`${option} requires a path`);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
20
31
|
if (args.includes('--help') || args.includes('-h')) {
|
|
21
|
-
cliOut('Usage: tungsten compile [targets] [--all] [--watch] [--no-clean]');
|
|
32
|
+
cliOut('Usage: tungsten compile [targets] [--all] [--watch] [--no-clean] [--output <dir>]');
|
|
22
33
|
cliOut('Targets: --js, --css, --client, --assets, --public');
|
|
23
34
|
cliOut('With no target options, all targets are compiled.');
|
|
35
|
+
cliOut('Options: --output <dir>, --ready-file <file>, --quiet');
|
|
24
36
|
process.exit(0);
|
|
25
37
|
}
|
|
26
|
-
const commandOptions = new Set(['--all', '--watch', '--no-clean']);
|
|
27
|
-
const
|
|
38
|
+
const commandOptions = new Set(['--all', '--watch', '--no-clean', '--quiet']);
|
|
39
|
+
const valueOptions = new Set(['--output', '--ready-file']);
|
|
40
|
+
const optionValues = new Set();
|
|
41
|
+
for (const option of valueOptions) {
|
|
42
|
+
const position = args.indexOf(option);
|
|
43
|
+
if (position !== -1 && args[position + 1] !== undefined) optionValues.add(args[position + 1]);
|
|
44
|
+
}
|
|
45
|
+
const unknownOptions = args.filter(arg => !(arg in targetOptions) && !commandOptions.has(arg) && !valueOptions.has(arg) && !optionValues.has(arg));
|
|
28
46
|
if (unknownOptions.length > 0) {
|
|
29
47
|
cliError(`Unknown compile option${unknownOptions.length === 1 ? '' : 's'}: ${unknownOptions.join(', ')}`);
|
|
30
|
-
cliOut('Usage: tungsten compile [targets] [--all] [--watch] [--no-clean]');
|
|
48
|
+
cliOut('Usage: tungsten compile [targets] [--all] [--watch] [--no-clean] [--output <dir>]');
|
|
31
49
|
process.exit(1);
|
|
32
50
|
}
|
|
51
|
+
const outputOption = optionValue('--output');
|
|
52
|
+
const readyFileOption = optionValue('--ready-file');
|
|
33
53
|
const requestedTargets = new Set();
|
|
34
54
|
for (const arg of args) {
|
|
35
55
|
const target = targetOptions[arg];
|
|
@@ -38,17 +58,43 @@ for (const arg of args) {
|
|
|
38
58
|
const targets = requestedTargets.size === 0 || args.includes('--all') ? new Set(['js', 'css', 'client', 'assets', 'public']) : requestedTargets;
|
|
39
59
|
const watch = args.includes('--watch');
|
|
40
60
|
const clean = !args.includes('--no-clean');
|
|
61
|
+
const quiet = args.includes('--quiet');
|
|
41
62
|
const projectDir = process.cwd();
|
|
42
63
|
const config = await getUserConfig();
|
|
43
64
|
const codeLocation = join(projectDir, config.codeDir);
|
|
44
65
|
const relSourceDir = config.sourceDir !== undefined && config.sourceDir !== '' ? config.sourceDir : config.codeDir;
|
|
45
66
|
const sourceLocation = join(projectDir, relSourceDir);
|
|
46
67
|
const styleImportBase = config.styleImportBase !== undefined ? join(sourceLocation, config.styleImportBase) : sourceLocation;
|
|
47
|
-
const buildLocation = join(projectDir, devBuildOuterFolder);
|
|
68
|
+
const buildLocation = outputOption !== undefined ? resolve(projectDir, outputOption) : join(projectDir, devBuildOuterFolder);
|
|
48
69
|
const buildCodeLocation = join(buildLocation, buildCodeSubPath);
|
|
70
|
+
const packagesCacheLocation = outputOption !== undefined ? join(buildLocation, '.packagesCache') : join(projectDir, packagesCacheFolder);
|
|
71
|
+
const readyFileLocation = readyFileOption !== undefined ? resolve(projectDir, readyFileOption) : undefined;
|
|
72
|
+
if (buildLocation.toLowerCase() === resolve(projectDir).toLowerCase()) {
|
|
73
|
+
cliError('Compile output cannot be the project root');
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
async function clearReadyFile() {
|
|
77
|
+
if (readyFileLocation !== undefined) await rmfr(readyFileLocation);
|
|
78
|
+
}
|
|
79
|
+
async function markReady() {
|
|
80
|
+
if (readyFileLocation === undefined) return;
|
|
81
|
+
await fsPromises.mkdir(dirname(readyFileLocation), {
|
|
82
|
+
recursive: true
|
|
83
|
+
});
|
|
84
|
+
const temporaryLocation = `${readyFileLocation}.${process.pid}.tmp`;
|
|
85
|
+
await fsPromises.writeFile(temporaryLocation, JSON.stringify({
|
|
86
|
+
ready: true,
|
|
87
|
+
output: buildLocation,
|
|
88
|
+
targets: [...targets],
|
|
89
|
+
updatedAt: new Date().toISOString()
|
|
90
|
+
}));
|
|
91
|
+
await rmfr(readyFileLocation);
|
|
92
|
+
await fsPromises.rename(temporaryLocation, readyFileLocation);
|
|
93
|
+
}
|
|
94
|
+
await clearReadyFile();
|
|
49
95
|
const cleanTasks = [];
|
|
50
96
|
if (clean && targets.has('js')) {
|
|
51
|
-
cleanTasks.push(rmfr(buildCodeLocation), rmfr(join(buildLocation, componentCssFolder)), rmfr(join(buildLocation, packagesFolder)), rmfr(
|
|
97
|
+
cleanTasks.push(rmfr(buildCodeLocation), rmfr(join(buildLocation, componentCssFolder)), rmfr(join(buildLocation, packagesFolder)), rmfr(packagesCacheLocation));
|
|
52
98
|
}
|
|
53
99
|
if (clean && targets.has('css')) {
|
|
54
100
|
cleanTasks.push(rmfr(join(buildLocation, staticFolder)));
|
|
@@ -63,15 +109,32 @@ if (clean) {
|
|
|
63
109
|
await Promise.all(cleanTasks);
|
|
64
110
|
}
|
|
65
111
|
const compilationTasks = [];
|
|
112
|
+
let javascriptInitialSuccess = true;
|
|
66
113
|
if (targets.has('js')) {
|
|
67
|
-
|
|
114
|
+
const javascriptTask = compileJavascript(projectDir, config, codeLocation, sourceLocation, styleImportBase, buildLocation, buildCodeLocation, 'dev', watch, {
|
|
115
|
+
quiet,
|
|
116
|
+
packagesCacheLocation,
|
|
117
|
+
onCycleComplete: watch ? async cycle => {
|
|
118
|
+
if (cycle.success) {
|
|
119
|
+
await markReady();
|
|
120
|
+
cliNews(`Compile cycle complete: js${cycle.file ? ` (${cycle.file})` : ''}`);
|
|
121
|
+
} else {
|
|
122
|
+
await clearReadyFile();
|
|
123
|
+
cliError(`Compile cycle failed: js${cycle.file ? ` (${cycle.file})` : ''}`);
|
|
124
|
+
}
|
|
125
|
+
} : undefined
|
|
126
|
+
});
|
|
127
|
+
compilationTasks.push(javascriptTask.then(result => {
|
|
128
|
+
javascriptInitialSuccess = result.initialSuccess;
|
|
129
|
+
return result;
|
|
130
|
+
}));
|
|
68
131
|
}
|
|
69
132
|
if (targets.has('css')) {
|
|
70
133
|
compilationTasks.push(compileStyles(projectDir, config, styleImportBase, buildLocation, watch));
|
|
71
134
|
}
|
|
72
135
|
if (targets.has('client')) {
|
|
73
|
-
compilationTasks.push(createInstanceConfigFile(config, 'dev'));
|
|
74
|
-
compilationTasks.push(createClientFiles(config, 'dev'));
|
|
136
|
+
compilationTasks.push(createInstanceConfigFile(config, 'dev', buildLocation));
|
|
137
|
+
compilationTasks.push(createClientFiles(config, 'dev', buildLocation));
|
|
75
138
|
}
|
|
76
139
|
if (targets.has('assets')) {
|
|
77
140
|
const assetsTask = copyAssets(projectDir, config, buildLocation, watch);
|
|
@@ -80,10 +143,21 @@ if (targets.has('assets')) {
|
|
|
80
143
|
if (targets.has('public')) {
|
|
81
144
|
compilationTasks.push(copyPublicFiles(projectDir, config, buildLocation, watch));
|
|
82
145
|
}
|
|
83
|
-
await Promise.
|
|
84
|
-
|
|
146
|
+
const compilationResults = await Promise.allSettled(compilationTasks);
|
|
147
|
+
const failures = compilationResults.filter(result => result.status === 'rejected').map(result => result.reason);
|
|
148
|
+
const initialSuccess = failures.length === 0 && javascriptInitialSuccess;
|
|
149
|
+
if (initialSuccess) {
|
|
150
|
+
await markReady();
|
|
151
|
+
cliNews(`Compile complete: ${[...targets].join(', ')}`);
|
|
152
|
+
} else {
|
|
153
|
+
await clearReadyFile();
|
|
154
|
+
cliError(`Compile failed: ${[...targets].join(', ')}`);
|
|
155
|
+
}
|
|
156
|
+
if (!watch && !initialSuccess) {
|
|
157
|
+
throw new AggregateError(failures, 'Compilation failed');
|
|
158
|
+
}
|
|
85
159
|
if (watch && (targets.has('js') || targets.has('css') || targets.has('assets') || targets.has('public'))) {
|
|
86
|
-
cliNews('Watching for changes');
|
|
160
|
+
cliNews(initialSuccess ? 'Watching for changes' : 'Watching for changes; waiting for a successful cycle');
|
|
87
161
|
} else {
|
|
88
162
|
// The underlying development compilers watch after their initial pass.
|
|
89
163
|
// End them when this command is being used for one-shot test preparation.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile.sxyt.d.ts","sourceRoot":"","sources":["../../../src/bin/commands/compile.sxyt.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { execFile } from 'child_process';
|
|
2
|
+
import { mkdir, mkdtemp, readFile, rm, writeFile } from 'fs/promises';
|
|
3
|
+
import { tmpdir } from 'os';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
import { promisify } from 'util';
|
|
6
|
+
import { expect } from 'chai';
|
|
7
|
+
import { describe } from 'sxy-test-runner';
|
|
8
|
+
import { findProjectDir } from "../../findProjectDir.js";
|
|
9
|
+
const execFileAsync = promisify(execFile);
|
|
10
|
+
describe('tungsten compile', ({
|
|
11
|
+
it
|
|
12
|
+
}) => {
|
|
13
|
+
it('exits non-zero and does not report completion when Babel cannot transform a file', async () => {
|
|
14
|
+
const projectDir = await mkdtemp(join(tmpdir(), 'tungsten-compile-test-'));
|
|
15
|
+
const cliLocation = join(findProjectDir(import.meta.url), 'dist', 'bin', 'index.js');
|
|
16
|
+
try {
|
|
17
|
+
await writeFile(join(projectDir, 'package.json'), '{"type":"module"}');
|
|
18
|
+
await writeFile(join(projectDir, 'broken.jsx'), 'export const broken = <div>');
|
|
19
|
+
let error;
|
|
20
|
+
try {
|
|
21
|
+
await execFileAsync(process.execPath, [cliLocation, 'compile', '--js', '--quiet'], {
|
|
22
|
+
cwd: projectDir
|
|
23
|
+
});
|
|
24
|
+
} catch (caught) {
|
|
25
|
+
error = caught;
|
|
26
|
+
}
|
|
27
|
+
expect(error).not.to.equal(undefined);
|
|
28
|
+
expect(error?.code).not.to.equal(0);
|
|
29
|
+
expect(error?.stdout ?? '').not.to.contain('Compile complete');
|
|
30
|
+
} finally {
|
|
31
|
+
await rm(projectDir, {
|
|
32
|
+
recursive: true,
|
|
33
|
+
force: true
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
it('writes all JavaScript and readiness output beneath the selected locations', async () => {
|
|
38
|
+
const projectDir = await mkdtemp(join(tmpdir(), 'tungsten-compile-output-test-'));
|
|
39
|
+
const cliLocation = join(findProjectDir(import.meta.url), 'dist', 'bin', 'index.js');
|
|
40
|
+
try {
|
|
41
|
+
await writeFile(join(projectDir, 'package.json'), '{"type":"module"}');
|
|
42
|
+
await writeFile(join(projectDir, 'entry.jsx'), 'export const element = <div />');
|
|
43
|
+
const {
|
|
44
|
+
stdout
|
|
45
|
+
} = await execFileAsync(process.execPath, [cliLocation, 'compile', '--js', '--output', '.tungsten/test', '--ready-file', '.tungsten/test.ready', '--quiet'], {
|
|
46
|
+
cwd: projectDir
|
|
47
|
+
});
|
|
48
|
+
const compiled = await readFile(join(projectDir, '.tungsten/test/code/entry.js'), 'utf8');
|
|
49
|
+
const ready = JSON.parse(await readFile(join(projectDir, '.tungsten/test.ready'), 'utf8'));
|
|
50
|
+
expect(stdout).to.contain('Compile complete');
|
|
51
|
+
expect(compiled).to.contain('export const element');
|
|
52
|
+
expect(ready.ready).to.equal(true);
|
|
53
|
+
expect(ready.output).to.equal(join(projectDir, '.tungsten/test'));
|
|
54
|
+
} finally {
|
|
55
|
+
await rm(projectDir, {
|
|
56
|
+
recursive: true,
|
|
57
|
+
force: true
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
it('reports an unsupported node dependency once and continues compiling', async () => {
|
|
62
|
+
const projectDir = await mkdtemp(join(tmpdir(), 'tungsten-compile-node-dependency-test-'));
|
|
63
|
+
const cliLocation = join(findProjectDir(import.meta.url), 'dist', 'bin', 'index.js');
|
|
64
|
+
const packageDir = join(projectDir, 'node_modules', 'fixture-package');
|
|
65
|
+
const sourceDir = join(projectDir, 'src');
|
|
66
|
+
try {
|
|
67
|
+
await mkdir(packageDir, {
|
|
68
|
+
recursive: true
|
|
69
|
+
});
|
|
70
|
+
await mkdir(sourceDir, {
|
|
71
|
+
recursive: true
|
|
72
|
+
});
|
|
73
|
+
await writeFile(join(projectDir, 'package.json'), '{"type":"module"}');
|
|
74
|
+
await writeFile(join(projectDir, 'tungsten.config.js'), 'export default { codeDir: "src", useRootComponent: false }');
|
|
75
|
+
await writeFile(join(sourceDir, 'entry.js'), 'import fixture from \'fixture-package\'; export { fixture }');
|
|
76
|
+
await writeFile(join(packageDir, 'package.json'), '{"name":"fixture-package","version":"1.0.0","main":"index.js"}');
|
|
77
|
+
await writeFile(join(packageDir, 'index.js'), 'module.exports = require(\'missing-native-module\')');
|
|
78
|
+
const {
|
|
79
|
+
stdout
|
|
80
|
+
} = await execFileAsync(process.execPath, [cliLocation, 'compile', '--js', '--output', '.tungsten/test', '--quiet'], {
|
|
81
|
+
cwd: projectDir
|
|
82
|
+
});
|
|
83
|
+
expect(stdout).to.contain('Your code that is compiled may depend on a node module - this is not allowed.');
|
|
84
|
+
expect(stdout).to.contain('src/entry.js\n -> fixture-package/index.js\n -> missing-native-module (unresolved)');
|
|
85
|
+
expect(stdout).not.to.contain('Require stack:');
|
|
86
|
+
expect(stdout).not.to.contain('process file err');
|
|
87
|
+
expect(stdout.split('Your code that is compiled may depend on a node module - this is not allowed.')).to.have.length(2);
|
|
88
|
+
expect(stdout).to.contain('Compile complete');
|
|
89
|
+
await readFile(join(projectDir, '.tungsten/test/code/entry.js'), 'utf8');
|
|
90
|
+
} finally {
|
|
91
|
+
await rm(projectDir, {
|
|
92
|
+
recursive: true,
|
|
93
|
+
force: true
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
it('skips package compilation for files selected by a JavaScript glob', async () => {
|
|
98
|
+
const projectDir = await mkdtemp(join(tmpdir(), 'tungsten-skip-package-compilation-test-'));
|
|
99
|
+
const cliLocation = join(findProjectDir(import.meta.url), 'dist', 'bin', 'index.js');
|
|
100
|
+
const packageDir = join(projectDir, 'node_modules', 'fixture-package');
|
|
101
|
+
const sourceDir = join(projectDir, 'src');
|
|
102
|
+
try {
|
|
103
|
+
await mkdir(packageDir, {
|
|
104
|
+
recursive: true
|
|
105
|
+
});
|
|
106
|
+
await mkdir(sourceDir, {
|
|
107
|
+
recursive: true
|
|
108
|
+
});
|
|
109
|
+
await writeFile(join(projectDir, 'package.json'), '{"type":"module"}');
|
|
110
|
+
await writeFile(join(projectDir, 'tungsten.config.js'), 'export default {' + ' codeDir: "src",' + ' useRootComponent: false,' + ' skipPackageCompilation: "**/*.domTest.js"' + ' }');
|
|
111
|
+
await writeFile(join(sourceDir, 'component.domTest.js'), "import fixture from 'fixture-package'; export { fixture }");
|
|
112
|
+
await writeFile(join(packageDir, 'package.json'), '{"name":"fixture-package","version":"1.0.0","main":"index.js"}');
|
|
113
|
+
await writeFile(join(packageDir, 'index.js'), 'module.exports = 1');
|
|
114
|
+
const {
|
|
115
|
+
stdout
|
|
116
|
+
} = await execFileAsync(process.execPath, [cliLocation, 'compile', '--js', '--output', '.tungsten/test', '--quiet'], {
|
|
117
|
+
cwd: projectDir
|
|
118
|
+
});
|
|
119
|
+
const compiled = await readFile(join(projectDir, '.tungsten/test/code/component.domTest.js'), 'utf8');
|
|
120
|
+
expect(stdout).to.contain('Compile complete');
|
|
121
|
+
expect(compiled).to.contain("from 'fixture-package'");
|
|
122
|
+
let packageWasCopied = true;
|
|
123
|
+
try {
|
|
124
|
+
await readFile(join(projectDir, '.tungsten/test/.packages/fixture-package@1.0.0/index.js'), 'utf8');
|
|
125
|
+
} catch {
|
|
126
|
+
packageWasCopied = false;
|
|
127
|
+
}
|
|
128
|
+
expect(packageWasCopied).to.equal(false);
|
|
129
|
+
} finally {
|
|
130
|
+
await rm(projectDir, {
|
|
131
|
+
recursive: true,
|
|
132
|
+
force: true
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
@@ -6,7 +6,17 @@ type CompileJavascriptResult = {
|
|
|
6
6
|
watcher: chokidar.FSWatcher | null;
|
|
7
7
|
copyWatcher: chokidar.FSWatcher | null;
|
|
8
8
|
importAliases: ImportAliases;
|
|
9
|
+
initialSuccess: boolean;
|
|
9
10
|
};
|
|
10
|
-
export
|
|
11
|
+
export type JavascriptCompilationCycle = {
|
|
12
|
+
success: boolean;
|
|
13
|
+
file?: string;
|
|
14
|
+
};
|
|
15
|
+
export type CompileJavascriptOptions = {
|
|
16
|
+
quiet?: boolean;
|
|
17
|
+
packagesCacheLocation?: string;
|
|
18
|
+
onCycleComplete?: ((cycle: JavascriptCompilationCycle) => void | Promise<void>) | undefined;
|
|
19
|
+
};
|
|
20
|
+
export declare function compileJavascript(projectDir: string, appConfig: FrameworkConfigComplete, codeLocation: string, sourceLocation: string, styleImportBase: string, buildLocation: string, buildCodeLocation: string, mode: Mode, watch?: boolean, options?: CompileJavascriptOptions): Promise<CompileJavascriptResult>;
|
|
11
21
|
export {};
|
|
12
22
|
//# sourceMappingURL=compileJavascript.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compileJavascript.d.ts","sourceRoot":"","sources":["../../src/build/compileJavascript.ts"],"names":[],"mappings":"AAEA,OAAO,QAAQ,MAAM,UAAU,CAAA;AAO/B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAetC,KAAK,uBAAuB,GAAG;IAC3B,OAAO,EAAE,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAA;IAClC,WAAW,EAAE,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAA;IACtC,aAAa,EAAE,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"compileJavascript.d.ts","sourceRoot":"","sources":["../../src/build/compileJavascript.ts"],"names":[],"mappings":"AAEA,OAAO,QAAQ,MAAM,UAAU,CAAA;AAO/B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAetC,KAAK,uBAAuB,GAAG;IAC3B,OAAO,EAAE,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAA;IAClC,WAAW,EAAE,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAA;IACtC,aAAa,EAAE,aAAa,CAAA;IAC5B,cAAc,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG;IACrC,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACnC,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,eAAe,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,0BAA0B,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,CAAA;CAC9F,CAAA;AAKD,wBAAsB,iBAAiB,CACnC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,uBAAuB,EACtD,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EACrE,aAAa,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,UAAO,EAC1E,OAAO,GAAE,wBAA6B,GACvC,OAAO,CAAC,uBAAuB,CAAC,CAuTlC"}
|
|
@@ -13,7 +13,7 @@ import { TungstenError } from "../TungstenError.js";
|
|
|
13
13
|
import { getFrameworkDir } from "../getFrameworkDir.js";
|
|
14
14
|
///// needs work to work in prod mode
|
|
15
15
|
///// see babel config
|
|
16
|
-
export async function compileJavascript(projectDir, appConfig, codeLocation, sourceLocation, styleImportBase, buildLocation, buildCodeLocation, mode, watch = true) {
|
|
16
|
+
export async function compileJavascript(projectDir, appConfig, codeLocation, sourceLocation, styleImportBase, buildLocation, buildCodeLocation, mode, watch = true, options = {}) {
|
|
17
17
|
cliOut(`Compiling app code`);
|
|
18
18
|
let dependencyGraphDir = '';
|
|
19
19
|
let dependencyGraphLocation = '';
|
|
@@ -22,14 +22,25 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
|
|
|
22
22
|
let importAliases = {};
|
|
23
23
|
let promises = [];
|
|
24
24
|
let config;
|
|
25
|
+
const skipPackageCompilationPatterns = appConfig.skipPackageCompilation === undefined ? [] : Array.isArray(appConfig.skipPackageCompilation) ? appConfig.skipPackageCompilation : [appConfig.skipPackageCompilation];
|
|
26
|
+
const skipPackageCompilationFiles = new Set();
|
|
27
|
+
async function refreshSkipPackageCompilationFiles() {
|
|
28
|
+
skipPackageCompilationFiles.clear();
|
|
29
|
+
const matchingFiles = await globby(skipPackageCompilationPatterns, {
|
|
30
|
+
cwd: codeLocation,
|
|
31
|
+
absolute: true
|
|
32
|
+
});
|
|
33
|
+
for (const file of matchingFiles) skipPackageCompilationFiles.add(slash(file));
|
|
34
|
+
}
|
|
35
|
+
await refreshSkipPackageCompilationFiles();
|
|
25
36
|
if (mode === 'dev') {
|
|
26
|
-
dependencyGraphDir = join(projectDir, packagesCacheFolder);
|
|
37
|
+
dependencyGraphDir = options.packagesCacheLocation ?? join(projectDir, packagesCacheFolder);
|
|
27
38
|
dependencyGraphLocation = join(dependencyGraphDir, '.dependency-graph.js');
|
|
28
39
|
oldDependencyGraph = {};
|
|
29
40
|
dependencyGraph = {};
|
|
30
41
|
importAliases = {};
|
|
31
42
|
promises = [];
|
|
32
|
-
config = makeBabelUserDevConfig(projectDir, codeLocation, sourceLocation, styleImportBase, buildLocation, buildCodeLocation, oldDependencyGraph, dependencyGraph, importAliases, promises);
|
|
43
|
+
config = makeBabelUserDevConfig(projectDir, codeLocation, sourceLocation, styleImportBase, buildLocation, buildCodeLocation, dependencyGraphDir, skipPackageCompilationFiles, oldDependencyGraph, dependencyGraph, importAliases, promises);
|
|
33
44
|
} else {
|
|
34
45
|
config = makeBabelUserProdConfig(projectDir, codeLocation, sourceLocation, styleImportBase);
|
|
35
46
|
}
|
|
@@ -37,8 +48,9 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
|
|
|
37
48
|
// compile with the API
|
|
38
49
|
const codeLocationLength = codeLocation.length + 1;
|
|
39
50
|
const transformPromises = [];
|
|
51
|
+
const failedFiles = new Set();
|
|
40
52
|
async function transformFile(file) {
|
|
41
|
-
console.log('transforming file', file);
|
|
53
|
+
if (!options.quiet) console.log('transforming file', file);
|
|
42
54
|
try {
|
|
43
55
|
let rel = file.slice(codeLocationLength);
|
|
44
56
|
if (rel.endsWith('.jsx')) rel = rel.slice(0, -1);
|
|
@@ -57,12 +69,26 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
|
|
|
57
69
|
//// Using the sync version here, because the promise version keeps bugging out - node bug?
|
|
58
70
|
//await fsPromises.writeFile(dest, code)
|
|
59
71
|
fs.writeFileSync(dest, code);
|
|
72
|
+
failedFiles.delete(file);
|
|
60
73
|
} catch (e) {
|
|
74
|
+
failedFiles.add(file);
|
|
61
75
|
cliError(`Tungsten: Error transforming project file ${file}`);
|
|
62
76
|
cliLog(e);
|
|
63
|
-
|
|
77
|
+
throw e;
|
|
64
78
|
}
|
|
65
79
|
}
|
|
80
|
+
async function deleteTransformedFile(file) {
|
|
81
|
+
let rel = file.slice(codeLocationLength);
|
|
82
|
+
if (rel.endsWith('.jsx')) rel = rel.slice(0, -1);
|
|
83
|
+
const dest = join(buildCodeLocation, rel);
|
|
84
|
+
try {
|
|
85
|
+
await fsPromises.unlink(dest);
|
|
86
|
+
} catch (error) {
|
|
87
|
+
const fileError = error;
|
|
88
|
+
if (fileError.code !== 'ENOENT') throw error;
|
|
89
|
+
}
|
|
90
|
+
failedFiles.delete(file);
|
|
91
|
+
}
|
|
66
92
|
async function copyFile(file) {
|
|
67
93
|
try {
|
|
68
94
|
let rel = file.slice(codeLocationLength);
|
|
@@ -94,6 +120,7 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
|
|
|
94
120
|
// get a list of files
|
|
95
121
|
const watchGlob = slash(`${codeLocation}/**/*.js{,x}`);
|
|
96
122
|
const ignored = [];
|
|
123
|
+
ignored.push(slash(`${buildLocation}/**`));
|
|
97
124
|
if (appConfig.ignoreDirs) {
|
|
98
125
|
ignored.push(...appConfig.ignoreDirs.map(folder => slash(`${codeLocation}/${folder}/**`)));
|
|
99
126
|
}
|
|
@@ -118,21 +145,38 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
|
|
|
118
145
|
paths.forEach(file => {
|
|
119
146
|
transformPromises.push(transformFile(file));
|
|
120
147
|
});
|
|
121
|
-
await Promise.
|
|
148
|
+
const transformResults = await Promise.allSettled(transformPromises);
|
|
149
|
+
const transformFailures = transformResults.filter(result => result.status === 'rejected').map(result => result.reason);
|
|
150
|
+
let deferredWorkPosition = 0;
|
|
151
|
+
const settleDeferredWork = async () => {
|
|
152
|
+
const currentPromises = promises.slice(deferredWorkPosition);
|
|
153
|
+
deferredWorkPosition = promises.length;
|
|
154
|
+
const deferredResults = await Promise.allSettled(currentPromises);
|
|
155
|
+
return deferredResults.filter(result => result.status === 'rejected').map(result => result.reason);
|
|
156
|
+
};
|
|
157
|
+
const initialFailures = [...transformFailures, ...(await settleDeferredWork())];
|
|
158
|
+
const initialSuccess = initialFailures.length === 0 && failedFiles.size === 0;
|
|
159
|
+
function writeDependencyGraph() {
|
|
160
|
+
if (mode !== 'dev') return;
|
|
161
|
+
if (!fs.existsSync(dependencyGraphDir)) {
|
|
162
|
+
fs.mkdirSync(dependencyGraphDir, {
|
|
163
|
+
recursive: true
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
fs.writeFileSync(dependencyGraphLocation, `export const graph = ${serializeJavascript(dependencyGraph)}`);
|
|
167
|
+
}
|
|
122
168
|
if (!watch) {
|
|
169
|
+
if (!initialSuccess) {
|
|
170
|
+
throw new AggregateError(initialFailures, 'One or more JavaScript files could not be compiled');
|
|
171
|
+
}
|
|
123
172
|
if (mode === 'dev') {
|
|
124
|
-
|
|
125
|
-
if (!fs.existsSync(dependencyGraphDir)) {
|
|
126
|
-
fs.mkdirSync(dependencyGraphDir, {
|
|
127
|
-
recursive: true
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
fs.writeFileSync(dependencyGraphLocation, `export const graph = ${serializeJavascript(dependencyGraph)}`);
|
|
173
|
+
writeDependencyGraph();
|
|
131
174
|
}
|
|
132
175
|
return {
|
|
133
176
|
watcher: null,
|
|
134
177
|
copyWatcher: null,
|
|
135
|
-
importAliases
|
|
178
|
+
importAliases,
|
|
179
|
+
initialSuccess
|
|
136
180
|
};
|
|
137
181
|
}
|
|
138
182
|
const watcher = chokidar.watch(watchGlob, {
|
|
@@ -140,13 +184,33 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
|
|
|
140
184
|
ignoreInitial: true
|
|
141
185
|
//useFsEvents: false
|
|
142
186
|
});
|
|
143
|
-
|
|
187
|
+
let watchCycle = Promise.resolve();
|
|
188
|
+
watcher.on('all', (event, file) => {
|
|
144
189
|
file = slash(file);
|
|
145
|
-
if (event === 'add') {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
190
|
+
if (event === 'add' || event === 'change' || event === 'unlink') {
|
|
191
|
+
watchCycle = watchCycle.then(async () => {
|
|
192
|
+
let success = false;
|
|
193
|
+
try {
|
|
194
|
+
if (event === 'unlink') {
|
|
195
|
+
await deleteTransformedFile(file);
|
|
196
|
+
} else {
|
|
197
|
+
if (event === 'add') await refreshSkipPackageCompilationFiles();
|
|
198
|
+
await transformFile(file);
|
|
199
|
+
}
|
|
200
|
+
const failures = await settleDeferredWork();
|
|
201
|
+
success = failures.length === 0 && failedFiles.size === 0;
|
|
202
|
+
if (success) writeDependencyGraph();
|
|
203
|
+
} catch {
|
|
204
|
+
success = false;
|
|
205
|
+
}
|
|
206
|
+
await options.onCycleComplete?.({
|
|
207
|
+
success,
|
|
208
|
+
file
|
|
209
|
+
});
|
|
210
|
+
}).catch(error => {
|
|
211
|
+
cliError('Tungsten: Error completing JavaScript watch cycle');
|
|
212
|
+
cliLog(error);
|
|
213
|
+
});
|
|
150
214
|
}
|
|
151
215
|
});
|
|
152
216
|
let copyWatcher = null;
|
|
@@ -172,21 +236,14 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
|
|
|
172
236
|
if (copyWatcher) awaiting.set(copyWatcher, true);
|
|
173
237
|
watcher.on('ready', async () => {
|
|
174
238
|
//cliNews('App Built')
|
|
175
|
-
if (
|
|
176
|
-
await Promise.all(promises);
|
|
177
|
-
if (!fs.existsSync(dependencyGraphDir)) {
|
|
178
|
-
fs.mkdirSync(dependencyGraphDir, {
|
|
179
|
-
recursive: true
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
fs.writeFileSync(dependencyGraphLocation, `export const graph = ${serializeJavascript(dependencyGraph)}`);
|
|
183
|
-
}
|
|
239
|
+
if (initialSuccess) writeDependencyGraph();
|
|
184
240
|
awaiting.delete(watcher);
|
|
185
241
|
if (awaiting.size === 0) {
|
|
186
242
|
resolve({
|
|
187
243
|
watcher,
|
|
188
244
|
copyWatcher,
|
|
189
|
-
importAliases
|
|
245
|
+
importAliases,
|
|
246
|
+
initialSuccess
|
|
190
247
|
});
|
|
191
248
|
}
|
|
192
249
|
});
|
|
@@ -198,7 +255,8 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
|
|
|
198
255
|
resolve({
|
|
199
256
|
watcher,
|
|
200
257
|
copyWatcher,
|
|
201
|
-
importAliases
|
|
258
|
+
importAliases,
|
|
259
|
+
initialSuccess
|
|
202
260
|
});
|
|
203
261
|
}
|
|
204
262
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Mode } from '../Mode.js';
|
|
2
2
|
import { FrameworkConfigComplete } from '../FrameworkConfig.js';
|
|
3
|
-
export declare function createClientFiles(config: FrameworkConfigComplete, mode: Mode): Promise<void>;
|
|
3
|
+
export declare function createClientFiles(config: FrameworkConfigComplete, mode: Mode, buildLocation?: string): Promise<void>;
|
|
4
4
|
//# sourceMappingURL=createClientFiles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createClientFiles.d.ts","sourceRoot":"","sources":["../../src/build/createClientFiles.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAOtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAG/D,wBAAsB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"createClientFiles.d.ts","sourceRoot":"","sources":["../../src/build/createClientFiles.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAOtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAG/D,wBAAsB,iBAAiB,CACnC,MAAM,EAAE,uBAAuB,EAC/B,IAAI,EAAE,IAAI,EACV,aAAa,CAAC,EAAE,MAAM,iBAgFzB"}
|
|
@@ -3,9 +3,9 @@ import { join } from 'path';
|
|
|
3
3
|
import { buildCodeSubPath, devBuildOuterFolder, prodBuildFolder, clientFolder, frameworkDistFolder, frameworkClientFolder } from "../settings.js";
|
|
4
4
|
import { fixExtension } from "../fixExtension.js";
|
|
5
5
|
import { findProjectDir } from "../findProjectDir.js";
|
|
6
|
-
export async function createClientFiles(config, mode) {
|
|
6
|
+
export async function createClientFiles(config, mode, buildLocation) {
|
|
7
7
|
//console.log('creating entry file')
|
|
8
|
-
const specificBuildFolder = mode === 'dev' ? devBuildOuterFolder : prodBuildFolder;
|
|
8
|
+
const specificBuildFolder = buildLocation ?? join(process.cwd(), mode === 'dev' ? devBuildOuterFolder : prodBuildFolder);
|
|
9
9
|
const codeSubPath = `${buildCodeSubPath}/`;
|
|
10
10
|
const frameworkDir = findProjectDir(import.meta.url);
|
|
11
11
|
const routesLocation = config.routesLocation;
|
|
@@ -13,20 +13,20 @@ export async function createClientFiles(config, mode) {
|
|
|
13
13
|
const [routeFilePath, routesExportName] = routesLocation;
|
|
14
14
|
const promises = [
|
|
15
15
|
// ensure the folder exists
|
|
16
|
-
fsPromises.mkdir(join(
|
|
16
|
+
fsPromises.mkdir(join(specificBuildFolder, `${clientFolder}`), {
|
|
17
17
|
recursive: true
|
|
18
18
|
}),
|
|
19
19
|
// client.js file
|
|
20
20
|
fsPromises.copyFile(join(frameworkDir, frameworkDistFolder, frameworkClientFolder, 'client.js'),
|
|
21
21
|
// from
|
|
22
|
-
join(
|
|
22
|
+
join(specificBuildFolder, `${clientFolder}/client.js`)),
|
|
23
23
|
// cjsHelpers.js file
|
|
24
24
|
fsPromises.copyFile(join(frameworkDir, frameworkDistFolder, frameworkClientFolder, 'cjsHelpers.js'),
|
|
25
25
|
// from
|
|
26
|
-
join(
|
|
26
|
+
join(specificBuildFolder, `${clientFolder}/cjsHelpers.js`)),
|
|
27
27
|
// app routes stuff
|
|
28
|
-
fsPromises.writeFile(join(
|
|
29
|
-
const clientRootComponentFileLocation = join(
|
|
28
|
+
fsPromises.writeFile(join(specificBuildFolder, clientFolder, 'routes.js'), `export { ${routesExportName} as routes } from '../${codeSubPath}${fixExtension(routeFilePath)}'`)];
|
|
29
|
+
const clientRootComponentFileLocation = join(specificBuildFolder, clientFolder, 'RootComponent.js');
|
|
30
30
|
if (config.useRootComponent) {
|
|
31
31
|
const rootComponentRelFilePath = config.rootComponent;
|
|
32
32
|
const rcFile = rootComponentRelFilePath.split('/').pop();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Mode } from '../Mode.js';
|
|
2
2
|
import { FrameworkConfigComplete } from '../FrameworkConfig.js';
|
|
3
|
-
export declare function createInstanceConfigFile(config: FrameworkConfigComplete, mode: Mode): Promise<void>;
|
|
3
|
+
export declare function createInstanceConfigFile(config: FrameworkConfigComplete, mode: Mode, buildLocation?: string): Promise<void>;
|
|
4
4
|
//# sourceMappingURL=createInstanceConfigFile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createInstanceConfigFile.d.ts","sourceRoot":"","sources":["../../src/build/createInstanceConfigFile.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAI/D,wBAAsB,wBAAwB,
|
|
1
|
+
{"version":3,"file":"createInstanceConfigFile.d.ts","sourceRoot":"","sources":["../../src/build/createInstanceConfigFile.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAI/D,wBAAsB,wBAAwB,CAC1C,MAAM,EAAE,uBAAuB,EAC/B,IAAI,EAAE,IAAI,EACV,aAAa,CAAC,EAAE,MAAM,iBA6BzB"}
|
|
@@ -2,10 +2,10 @@ import { promises as fsPromises } from 'fs';
|
|
|
2
2
|
import { join, dirname } from 'path';
|
|
3
3
|
import { devBuildOuterFolder, prodBuildFolder } from "../settings.js";
|
|
4
4
|
import { TungstenError } from "../TungstenError.js";
|
|
5
|
-
export async function createInstanceConfigFile(config, mode) {
|
|
5
|
+
export async function createInstanceConfigFile(config, mode, buildLocation) {
|
|
6
6
|
//console.log('creating app config')
|
|
7
|
-
const specificBuildFolder = mode === 'dev' ? devBuildOuterFolder : prodBuildFolder;
|
|
8
|
-
const appConfigLocation = join(
|
|
7
|
+
const specificBuildFolder = buildLocation ?? join(process.cwd(), mode === 'dev' ? devBuildOuterFolder : prodBuildFolder);
|
|
8
|
+
const appConfigLocation = join(specificBuildFolder, '.tungsten.config.js');
|
|
9
9
|
// // ensure the folder exists
|
|
10
10
|
// await fsPromises.mkdir(
|
|
11
11
|
// join(process.cwd(), specificBuildFolder),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TransformOptions } from '@babel/core';
|
|
2
2
|
import type { ImportAliases } from './ImportAliases.js';
|
|
3
3
|
import { DependencyGraph } from '../babelPlugins/BabelTransformPackageImports.js';
|
|
4
|
-
export declare function makeBabelUserDevConfig(projectDir: string, absCodeDir: string, absSourceDir: string, absStyleImportBase: string, buildLocation: string, buildCodeLocation: string, oldDependencyGraph: DependencyGraph, dependencyGraph: DependencyGraph, importAliases: ImportAliases, promises: Promise<any>[]): TransformOptions;
|
|
4
|
+
export declare function makeBabelUserDevConfig(projectDir: string, absCodeDir: string, absSourceDir: string, absStyleImportBase: string, buildLocation: string, buildCodeLocation: string, packagesCacheLocation: string, skipPackageCompilationFiles: ReadonlySet<string>, oldDependencyGraph: DependencyGraph, dependencyGraph: DependencyGraph, importAliases: ImportAliases, promises: Promise<any>[]): TransformOptions;
|
|
5
5
|
//# sourceMappingURL=makeBabelUserDevConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"makeBabelUserDevConfig.d.ts","sourceRoot":"","sources":["../../src/build/makeBabelUserDevConfig.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAKnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD,OAAO,EAAoC,eAAe,EAAE,MAAM,iDAAiD,CAAA;AAMnH,wBAAgB,sBAAsB,CAClC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,kBAAkB,EAAE,MAAM,EAC1B,aAAa,EAAE,MAAM,EACrB,iBAAiB,EAAE,MAAM,EACzB,kBAAkB,EAAE,eAAe,EACnC,eAAe,EAAE,eAAe,EAChC,aAAa,EAAE,aAAa,EAC5B,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,GACzB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"makeBabelUserDevConfig.d.ts","sourceRoot":"","sources":["../../src/build/makeBabelUserDevConfig.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAKnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD,OAAO,EAAoC,eAAe,EAAE,MAAM,iDAAiD,CAAA;AAMnH,wBAAgB,sBAAsB,CAClC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,kBAAkB,EAAE,MAAM,EAC1B,aAAa,EAAE,MAAM,EACrB,iBAAiB,EAAE,MAAM,EACzB,qBAAqB,EAAE,MAAM,EAC7B,2BAA2B,EAAE,WAAW,CAAC,MAAM,CAAC,EAChD,kBAAkB,EAAE,eAAe,EACnC,eAAe,EAAE,eAAe,EAChC,aAAa,EAAE,aAAa,EAC5B,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,GACzB,gBAAgB,CA4BlB"}
|
|
@@ -6,13 +6,15 @@ import { MakeBabelTransformPackageImports } from "../babelPlugins/BabelTransform
|
|
|
6
6
|
import { componentCssFolder, componentCssFile } from "../settings.js";
|
|
7
7
|
import userCommonConfig from "./babel.user.common.config.js";
|
|
8
8
|
import { MakeBabelTransformCssImports } from "../babelPlugins/BabelTransformCssImports.js";
|
|
9
|
-
export function makeBabelUserDevConfig(projectDir, absCodeDir, absSourceDir, absStyleImportBase, buildLocation, buildCodeLocation, oldDependencyGraph, dependencyGraph, importAliases, promises) {
|
|
9
|
+
export function makeBabelUserDevConfig(projectDir, absCodeDir, absSourceDir, absStyleImportBase, buildLocation, buildCodeLocation, packagesCacheLocation, skipPackageCompilationFiles, oldDependencyGraph, dependencyGraph, importAliases, promises) {
|
|
10
10
|
const userDevConfig = objectCopy(userCommonConfig);
|
|
11
11
|
userDevConfig.plugins.push(MakeBabelTransformPackageImports({
|
|
12
12
|
projectDir: projectDir,
|
|
13
13
|
codeDir: absCodeDir,
|
|
14
14
|
buildLocation,
|
|
15
15
|
buildCodeLocation,
|
|
16
|
+
packagesCacheLocation,
|
|
17
|
+
skipPackageCompilationFiles,
|
|
16
18
|
oldDependencyGraph,
|
|
17
19
|
dependencyGraph,
|
|
18
20
|
importAliases,
|