tungsten 0.4.11 → 0.4.12
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/.build-complete +1 -1
- package/dist/AnyComponent.js +1 -1
- package/dist/Components.d.ts.map +1 -1
- package/dist/Components.js +15 -16
- package/dist/ContentNode.js +2 -2
- package/dist/DomRegion.js +1 -1
- package/dist/Framework.d.ts +2 -1
- package/dist/Framework.d.ts.map +1 -1
- package/dist/Framework.js +43 -34
- package/dist/FrameworkConfig.d.ts +16 -0
- package/dist/FrameworkConfig.d.ts.map +1 -1
- package/dist/FunctionComponentStandIn.js +8 -8
- package/dist/Instance/Instance.js +11 -11
- package/dist/RenderedContentNode.js +2 -2
- package/dist/RenderingNode.js +2 -2
- package/dist/Script.js +1 -1
- package/dist/Servers/DevServer.d.ts.map +1 -1
- package/dist/Servers/DevServer.js +29 -29
- package/dist/Servers/ProdServer.js +14 -14
- package/dist/Servers/StaticSiteServer.js +3 -3
- package/dist/Servers/TungstenServer.js +5 -5
- package/dist/Servers/devErrorPageAutoRetry.js +1 -1
- package/dist/Servers/hono/TungstenServerHono.js +5 -5
- package/dist/Servers/initStores.js +3 -3
- package/dist/Servers/loadEnvsDev.js +6 -6
- package/dist/Servers/routing.js +3 -3
- package/dist/Store/createStores.js +2 -2
- package/dist/Store/makeStore.js +2 -2
- package/dist/Store/registerStore.js +2 -2
- package/dist/TungstenApp.js +3 -3
- package/dist/TungstenStyleObject.js +1 -1
- package/dist/__deproxy.js +2 -2
- package/dist/_client/client.js +3 -3
- package/dist/alive.js +1 -1
- package/dist/api/getApiRoutes.js +3 -3
- package/dist/api/getApiRoutesHono.js +3 -3
- package/dist/api/getExport.js +4 -4
- package/dist/api/getExportDev.js +1 -1
- package/dist/appOutput.js +1 -1
- package/dist/auth/index.js +2 -2
- package/dist/babelPlugins/BabelAddDevCacheBust.d.ts.map +1 -1
- package/dist/babelPlugins/BabelAddDevCacheBust.js +4 -2
- package/dist/babelPlugins/BabelTransformBindDirect.js +2 -2
- package/dist/babelPlugins/BabelTransformBindVar.js +3 -3
- package/dist/babelPlugins/BabelTransformCjsToEsm.js +1 -1
- package/dist/babelPlugins/BabelTransformComponentState.js +2 -2
- package/dist/babelPlugins/BabelTransformComponentStyles.d.ts +2 -0
- package/dist/babelPlugins/BabelTransformComponentStyles.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTransformComponentStyles.js +27 -11
- package/dist/babelPlugins/BabelTransformCssImports.js +1 -1
- package/dist/babelPlugins/BabelTransformDeproxyState.js +1 -1
- package/dist/babelPlugins/BabelTransformJsxExtensionsToJs.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTransformJsxExtensionsToJs.js +6 -2
- package/dist/babelPlugins/BabelTransformPackageImports.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTransformPackageImports.js +66 -49
- package/dist/babelPlugins/BabelTransformReactive.js +1 -1
- package/dist/babelPlugins/BabelTransformReactiveSvelteStyle.js +1 -1
- package/dist/babelPlugins/BabelTransformSxyFrameworkImports.js +1 -1
- package/dist/babelPlugins/BabelTransformUniqueComponents.js +1 -1
- package/dist/babelPlugins/fixImportsInSassErrorMessage.js +1 -1
- package/dist/babelPlugins/test.js +1 -1
- package/dist/babelPlugins/transformPackageImports/BabelTransformDependencyImportsCjs.js +3 -3
- package/dist/babelPlugins/transformPackageImports/BabelTransformDependencyImportsEsm.js +1 -1
- package/dist/babelPlugins/transformPackageImports/getWebLocationOfPackageFile.js +2 -2
- package/dist/bin/args.js +1 -1
- package/dist/bin/commands/build.js +5 -5
- package/dist/bin/commands/buildHelp.js +1 -1
- package/dist/bin/commands/clean.js +4 -4
- package/dist/bin/commands/compile.d.ts.map +1 -1
- package/dist/bin/commands/compile.js +24 -17
- package/dist/bin/commands/compileSimplePackage.js +2 -2
- package/dist/bin/commands/dev.d.ts.map +1 -1
- package/dist/bin/commands/dev.js +16 -9
- package/dist/bin/commands/devmon.js +4 -4
- package/dist/bin/commands/help.js +2 -2
- package/dist/bin/commands/start.js +2 -2
- package/dist/bin/commands/static.js +3 -3
- package/dist/bin/index.js +13 -13
- package/dist/bin/moduleLoadAnalysis.js +2 -2
- package/dist/browserStorage.js +2 -2
- package/dist/build/babel.user.common.config.d.ts +7 -2
- package/dist/build/babel.user.common.config.d.ts.map +1 -1
- package/dist/build/babel.user.common.config.js +14 -15
- package/dist/build/bundle.d.ts +1 -1
- package/dist/build/bundle.d.ts.map +1 -1
- package/dist/build/bundle.js +15 -7
- package/dist/build/bundleBabelOptions.d.ts +6 -0
- package/dist/build/bundleBabelOptions.d.ts.map +1 -0
- package/dist/build/bundleBabelOptions.js +23 -0
- package/dist/build/combineComponentCss.js +2 -2
- package/dist/build/compileJavascript.d.ts +4 -0
- package/dist/build/compileJavascript.d.ts.map +1 -1
- package/dist/build/compileJavascript.js +148 -90
- package/dist/build/compileStyles.js +4 -4
- package/dist/build/compileUserApp.d.ts +1 -1
- package/dist/build/compileUserApp.d.ts.map +1 -1
- package/dist/build/compileUserApp.js +15 -12
- package/dist/build/componentStylesCache.d.ts +10 -0
- package/dist/build/componentStylesCache.d.ts.map +1 -0
- package/dist/build/componentStylesCache.js +54 -0
- package/dist/build/copyAssets.js +1 -1
- package/dist/build/copyPackageModulesToPackagesFolder.js +4 -4
- package/dist/build/copyPublicFiles.js +1 -1
- package/dist/build/createClientFiles.js +3 -3
- package/dist/build/createInstanceConfigFile.js +2 -2
- package/dist/build/createPackageVirtualFileSystems.js +1 -1
- package/dist/build/devBundle.js +5 -5
- package/dist/build/devBundle.rollup.config.d.ts.map +1 -1
- package/dist/build/devBundle.rollup.config.js +0 -1
- package/dist/build/frameworkDestLocation.d.ts +1 -0
- package/dist/build/frameworkDestLocation.d.ts.map +1 -1
- package/dist/build/frameworkDestLocation.js +8 -4
- package/dist/build/frameworkStylesheets.js +1 -1
- package/dist/build/getAllSxyClientModules.js +2 -2
- package/dist/build/getPackageDirForFile.js +1 -1
- package/dist/build/getSxyClientPackageAliases.d.ts.map +1 -1
- package/dist/build/getSxyClientPackageAliases.js +4 -2
- package/dist/build/getTempDirForAppCompilation.js +1 -1
- package/dist/build/makeBabelRawConfig.d.ts +3 -0
- package/dist/build/makeBabelRawConfig.d.ts.map +1 -0
- package/dist/build/makeBabelRawConfig.js +12 -0
- package/dist/build/makeBabelUserDevConfig.d.ts +1 -1
- package/dist/build/makeBabelUserDevConfig.d.ts.map +1 -1
- package/dist/build/makeBabelUserDevConfig.js +11 -8
- package/dist/build/makeBabelUserProdConfig.d.ts +1 -1
- package/dist/build/makeBabelUserProdConfig.d.ts.map +1 -1
- package/dist/build/makeBabelUserProdConfig.js +10 -5
- package/dist/build/processPackage.js +3 -3
- package/dist/build/rollup.user.prod.config.d.ts.map +1 -1
- package/dist/build/rollup.user.prod.config.js +13 -11
- package/dist/build/rollupExtractComponentStylesheets.js +2 -2
- package/dist/build/sassImportParser.js +2 -2
- package/dist/build/tallyBabelPlugins.d.ts.map +1 -1
- package/dist/build/tallyBabelPlugins.js +2 -7
- package/dist/calculateImportedStaticFileLocations.js +2 -2
- package/dist/calledFrom.js +2 -2
- package/dist/compat/forwardRef.js +1 -1
- package/dist/compat/index.js +1 -1
- package/dist/componentProxyHandlers.js +3 -3
- package/dist/components/Link.js +2 -2
- package/dist/components/PopMessages.js +3 -3
- package/dist/components/RawHtml.js +2 -2
- package/dist/components/Stylesheet.js +3 -3
- package/dist/components/bindable/BindableCheckbox.js +1 -1
- package/dist/components/bindable/BindableInput.js +1 -1
- package/dist/components/bindable/BindableInputNonString.js +1 -1
- package/dist/components/bindable/BindableInputString.js +1 -1
- package/dist/components/bindable/BindableInputTyped.js +1 -1
- package/dist/components/bindable/BindableInputTypedLegacy.js +1 -1
- package/dist/components/bindable/BindableRadio.js +1 -1
- package/dist/components/bindable/BindableSelect.js +1 -1
- package/dist/components/bindable/BindableTextarea.js +1 -1
- package/dist/components/library/RichTextEditor/RichTextEditor.js +8 -8
- package/dist/components/library/RichTextEditor/contentTree.js +4 -4
- package/dist/components/library/RichTextEditor/sanitizeAuthoredHtml.js +2 -2
- package/dist/components/library/__StatefulMessage/StatefulMessage.js +2 -2
- package/dist/components/library/index.js +2 -2
- package/dist/createElement.js +1 -1
- package/dist/defaultConfig.d.ts +0 -1
- package/dist/defaultConfig.d.ts.map +1 -1
- package/dist/defaultConfig.js +2 -2
- package/dist/deleteDirs.js +1 -1
- package/dist/env/addToEnv.js +1 -1
- package/dist/env/funcs.js +4 -4
- package/dist/env/getEnvSchemas.d.ts.map +1 -1
- package/dist/env/getEnvSchemas.js +10 -6
- package/dist/env/privateEnv.js +2 -2
- package/dist/env/privateEnvOrThrow.js +1 -1
- package/dist/env/publicEnv.js +1 -1
- package/dist/env/publicEnvOrThrow.js +1 -1
- package/dist/filePathFromUrl.js +1 -1
- package/dist/findProjectDir.js +1 -1
- package/dist/findUserConfig.js +5 -5
- package/dist/fixExtension.d.ts.map +1 -1
- package/dist/fixExtension.js +5 -3
- package/dist/frameworkConfigSchema.d.ts +16 -0
- package/dist/frameworkConfigSchema.d.ts.map +1 -1
- package/dist/frameworkConfigSchema.js +12 -0
- package/dist/getComponent.js +5 -5
- package/dist/getComponentDev.js +1 -1
- package/dist/getFrameworkDir.js +1 -1
- package/dist/getRoutes.js +5 -5
- package/dist/getRoutesDevs.js +1 -1
- package/dist/getUserConfig.js +7 -7
- package/dist/hasValidKey.js +1 -1
- package/dist/helpers/index.js +2 -2
- package/dist/hmr/applyHmrModule.js +5 -5
- package/dist/hmr/componentIdentity.js +2 -2
- package/dist/hooks/clearCurrentComponent.js +1 -1
- package/dist/hooks/getCurrentComponent.js +3 -3
- package/dist/hooks/index.js +5 -5
- package/dist/hooks/setCurrentComponent.js +1 -1
- package/dist/hooks/useCallback.js +2 -2
- package/dist/hooks/useEffect.js +2 -2
- package/dist/hooks/useInstance.js +1 -1
- package/dist/hooks/useMemo.js +2 -2
- package/dist/hooks/useState.js +3 -3
- package/dist/hydrate/hydrate.js +31 -31
- package/dist/hydrate/reconcileHydratedAttributes.js +3 -3
- package/dist/index.js +2 -2
- package/dist/indexInner.d.ts +1 -1
- package/dist/indexInner.d.ts.map +1 -1
- package/dist/indexInner.js +45 -45
- package/dist/innerHtmlFromProps.js +1 -1
- package/dist/isBrowser.js +1 -1
- package/dist/isDev.js +1 -1
- package/dist/isProd.js +1 -1
- package/dist/isServer.js +1 -1
- package/dist/jsx-runtime.js +1 -1
- package/dist/jsxRuntime.d.ts.map +1 -1
- package/dist/jsxRuntime.js +12 -7
- package/dist/jsxRuntimeSignals.d.ts.map +1 -1
- package/dist/jsxRuntimeSignals.js +15 -8
- package/dist/makeFinalConfig.js +1 -1
- package/dist/makeInstanceConfigFromFrameworkConfig.js +1 -1
- package/dist/makeServerRpc.js +3 -3
- package/dist/markOptionSelected.js +1 -1
- package/dist/nbsp.js +1 -1
- package/dist/output.js +1 -1
- package/dist/pop.js +2 -2
- package/dist/postcssPlugins/TransformCssNames.js +6 -6
- package/dist/postcssPlugins/parseSelectors.js +1 -1
- package/dist/postcssPlugins/parseSelectorsRich.js +1 -1
- package/dist/postcssPlugins/scopeAnimationValue.js +2 -2
- package/dist/propsAreEqual.js +3 -3
- package/dist/rawHtml/filterContentNode.js +4 -4
- package/dist/rawHtml/parseHtml.js +4 -4
- package/dist/rawHtml/sanitizeHtml.js +3 -3
- package/dist/rawHtml/tokenizeHtml.js +2 -2
- package/dist/render/addImportMap.js +2 -2
- package/dist/render/classComponentNodeToRenderingTree.js +4 -4
- package/dist/render/componentNodeToRenderingTree.js +7 -7
- package/dist/render/contentNodeToHtml.js +11 -11
- package/dist/render/contentToHtml.js +4 -4
- package/dist/render/contentToHtmlDev.js +1 -1
- package/dist/render/contentTreeToRenderingTree.js +7 -7
- package/dist/render/functionComponentNodeToRenderingTree.js +4 -4
- package/dist/render/getFunctionBodyAsString.js +1 -1
- package/dist/render/instantiateClassComponent.js +2 -2
- package/dist/render/instantiateComponent.js +3 -3
- package/dist/render/instantiateFunctionComponent.js +2 -2
- package/dist/render/printComponentNameInSource.js +1 -1
- package/dist/render/processHead.js +5 -5
- package/dist/render/processHtmlNode.js +1 -1
- package/dist/render/processProps.js +2 -2
- package/dist/render/processRenderingNodeHtml.js +6 -6
- package/dist/render/renderingTreeToHtml.js +16 -16
- package/dist/render/rootToHtml.js +2 -2
- package/dist/render/rootToHtmlDev.js +1 -1
- package/dist/requests/fetch/delete.js +2 -2
- package/dist/requests/fetch/get.js +3 -3
- package/dist/requests/fetch/patch.js +2 -2
- package/dist/requests/fetch/post.js +2 -2
- package/dist/requests/fetch/put.js +2 -2
- package/dist/requests/index.js +5 -5
- package/dist/routing/MatchedRoute.js +2 -2
- package/dist/routing/getPathPriority.js +1 -1
- package/dist/routing/matchPath.js +3 -3
- package/dist/routing/patternToRegex.js +1 -1
- package/dist/server.js +3 -3
- package/dist/serverModuleLocation.d.ts +3 -0
- package/dist/serverModuleLocation.d.ts.map +1 -0
- package/dist/serverModuleLocation.js +12 -0
- package/dist/settings.d.ts +4 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +9 -0
- package/dist/standardSchema.js +1 -1
- package/dist/staticGen/getAppRoutes.js +3 -3
- package/dist/staticGen/staticGen.js +7 -7
- package/dist/style/jssToCss.js +3 -3
- package/dist/style/styleContent.js +1 -1
- package/dist/style/styleContentSxy.js +8 -8
- package/dist/style/unusedStyles.js +1 -1
- package/dist/sync/index.js +1 -1
- package/dist/syncServer/preload.js +1 -1
- package/dist/testing/host.js +1 -1
- package/dist/testing/hydrateTestApp.js +9 -9
- package/dist/testing/index.js +11 -11
- package/dist/testing/installTestStyleProcessors.js +1 -1
- package/dist/testing/loadEnv.js +3 -3
- package/dist/testing/loadEnvSetup.js +1 -1
- package/dist/testing/temp/componentPackageMock.js +2 -2
- package/dist/testing/temp/contentHtmlElements.js +2 -2
- package/dist/throwError.js +2 -2
- package/dist/timeProfiler.d.ts +1 -1
- package/dist/timeProfiler.d.ts.map +1 -1
- package/dist/timeProfiler.js +61 -25
- package/dist/update/integrateUpdateVdom.js +28 -28
- package/dist/validChildren.js +2 -2
- package/dist/warnOnFrameworkChange.js +2 -2
- package/dist/zones/react.js +3 -3
- package/package.json +18 -11
- package/types/modules.d.ts +2 -0
|
@@ -6,21 +6,26 @@ import fs, { promises as fsPromises } from 'fs';
|
|
|
6
6
|
import slash from 'slash';
|
|
7
7
|
import serializeJavascript from 'serialize-javascript';
|
|
8
8
|
import { globby } from 'globby';
|
|
9
|
-
import { packagesCacheFolder } from
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
9
|
+
import { devRawBuildFolder, packagesCacheFolder, prodRawBuildFolder, stylesCacheFolder } from '../settings.js';
|
|
10
|
+
import { frameworkVersion } from './frameworkDestLocation.js';
|
|
11
|
+
import { makeBabelUserDevConfig } from './makeBabelUserDevConfig.js';
|
|
12
|
+
import { makeBabelUserProdConfig } from './makeBabelUserProdConfig.js';
|
|
13
|
+
import { makeBabelRawConfig } from './makeBabelRawConfig.js';
|
|
14
|
+
import { cliOut, cliLog, cliError, cliWarn } from '../cliOutput.js'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
15
|
+
import { createTimeProfiler, isProfiling, tallied } from '../timeProfiler.js';
|
|
16
|
+
import { tallyBabelPlugins } from './tallyBabelPlugins.js';
|
|
17
|
+
import { TungstenError } from '../TungstenError.js';
|
|
18
|
+
import { getFrameworkDir } from '../getFrameworkDir.js';
|
|
17
19
|
// The graph writeDependencyGraph() left behind on the previous run, naming a compiled copy of every
|
|
18
20
|
// package file in the packages cache. Missing or unreadable just means everything is compiled from
|
|
19
21
|
// source, which is what happened on every run before this was read back.
|
|
22
|
+
// Nodes are keyed by package version only, so a graph another tungsten version wrote is discarded:
|
|
23
|
+
// the transform may have changed. frameworkVersion here is a free option - any stamp works.
|
|
20
24
|
async function loadDependencyGraph(location) {
|
|
21
25
|
if (!fs.existsSync(location)) return {};
|
|
22
26
|
try {
|
|
23
27
|
const graphModule = await import(pathToFileURL(location).href);
|
|
28
|
+
if (graphModule.version !== frameworkVersion) return {};
|
|
24
29
|
return graphModule.graph ?? {};
|
|
25
30
|
} catch (error) {
|
|
26
31
|
cliWarn(`Could not read the package cache at ${location}, compiling packages from source`);
|
|
@@ -33,6 +38,9 @@ async function loadDependencyGraph(location) {
|
|
|
33
38
|
export async function compileJavascript(projectDir, appConfig, codeLocation, sourceLocation, styleImportBase, buildLocation, buildCodeLocation, mode, watch = true, options = {}) {
|
|
34
39
|
if (options.quiet !== true) cliOut(`Compiling app code`);
|
|
35
40
|
const compilePackages = options.packages !== false;
|
|
41
|
+
// codeLocation's .ts/.tsx are sources too, compiled to .js by babel; .d.ts is never one
|
|
42
|
+
const typescript = appConfig.typescript === true;
|
|
43
|
+
const rawBuildLocation = options.rawBuildLocation ?? join(projectDir, mode === 'dev' ? devRawBuildFolder : prodRawBuildFolder);
|
|
36
44
|
let dependencyGraphDir = '';
|
|
37
45
|
let dependencyGraphLocation = '';
|
|
38
46
|
let oldDependencyGraph = {};
|
|
@@ -54,35 +62,48 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
|
|
|
54
62
|
if (mode === 'dev') {
|
|
55
63
|
dependencyGraphDir = options.packagesCacheLocation ?? join(projectDir, packagesCacheFolder);
|
|
56
64
|
dependencyGraphLocation = join(dependencyGraphDir, '.dependency-graph.js');
|
|
57
|
-
oldDependencyGraph = await loadDependencyGraph(dependencyGraphLocation);
|
|
65
|
+
oldDependencyGraph = options.fresh === true ? {} : await loadDependencyGraph(dependencyGraphLocation);
|
|
58
66
|
dependencyGraph = {};
|
|
59
67
|
importAliases = {};
|
|
60
68
|
promises = [];
|
|
61
|
-
config = makeBabelUserDevConfig(projectDir, codeLocation, sourceLocation, styleImportBase, buildLocation, buildCodeLocation, dependencyGraphDir, skipPackageCompilationFiles, oldDependencyGraph, dependencyGraph, importAliases, promises, watch, options.hmr === true, compilePackages);
|
|
69
|
+
config = makeBabelUserDevConfig(projectDir, codeLocation, sourceLocation, typescript, styleImportBase, buildLocation, buildCodeLocation, dependencyGraphDir, options.stylesCacheLocation ?? join(projectDir, stylesCacheFolder), options.fresh === true, skipPackageCompilationFiles, oldDependencyGraph, dependencyGraph, importAliases, promises, watch, options.hmr === true, compilePackages);
|
|
62
70
|
} else {
|
|
63
|
-
config = makeBabelUserProdConfig(projectDir, codeLocation, sourceLocation, styleImportBase, watch);
|
|
71
|
+
config = makeBabelUserProdConfig(projectDir, codeLocation, sourceLocation, typescript, styleImportBase, watch);
|
|
64
72
|
}
|
|
65
73
|
config.root = getFrameworkDir();
|
|
74
|
+
const rawConfig = makeBabelRawConfig(typescript);
|
|
75
|
+
rawConfig.root = config.root;
|
|
66
76
|
// per-plugin attribution of the transform's time, only when someone is looking: the wrappers
|
|
67
77
|
// run per AST node
|
|
68
78
|
if (isProfiling()) {
|
|
69
79
|
config.plugins = tallyBabelPlugins(config.plugins);
|
|
80
|
+
rawConfig.plugins = tallyBabelPlugins(rawConfig.plugins);
|
|
70
81
|
if (mode === 'dev' && compilePackages) {
|
|
71
|
-
cliWarn(`profiling serves linked packages from the packages cache -` + `
|
|
82
|
+
cliWarn(`profiling serves linked packages from the packages cache -` + ` pass --fresh after rebuilding one, or this run compiles stale code`);
|
|
72
83
|
}
|
|
73
84
|
}
|
|
74
85
|
// compile with the API
|
|
75
86
|
const codeLocationLength = codeLocation.length + 1;
|
|
87
|
+
// a source's path within the build: every compiled extension becomes .js
|
|
88
|
+
function outputRel(file) {
|
|
89
|
+
const rel = file.slice(codeLocationLength);
|
|
90
|
+
if (rel.endsWith('.jsx')) return rel.slice(0, -1);
|
|
91
|
+
if (typescript && rel.endsWith('.tsx')) return `${rel.slice(0, -3)}js`;
|
|
92
|
+
if (typescript && rel.endsWith('.ts')) return `${rel.slice(0, -2)}js`;
|
|
93
|
+
return rel;
|
|
94
|
+
}
|
|
76
95
|
const transformPromises = [];
|
|
77
96
|
const failedFiles = new Set();
|
|
78
97
|
const pendingExportWipes = new Map();
|
|
79
98
|
const exportWipeGraceMs = 5000;
|
|
99
|
+
// A source goes through the client pipeline, the raw one, both, or neither - see
|
|
100
|
+
// refreshSelections() below for what decides that
|
|
80
101
|
async function transformFile(file) {
|
|
81
102
|
//if (options.quiet !== true) console.log('transforming file', file)
|
|
103
|
+
const client = isClient(file);
|
|
104
|
+
const raw = isRaw(file);
|
|
105
|
+
if (!client && !raw) return;
|
|
82
106
|
try {
|
|
83
|
-
let rel = file.slice(codeLocationLength);
|
|
84
|
-
if (rel.endsWith('.jsx')) rel = rel.slice(0, -1);
|
|
85
|
-
const dest = join(buildCodeLocation, rel);
|
|
86
107
|
// tsc's own watch/incremental emit can leave this file genuinely blank for a
|
|
87
108
|
// stretch while it recomputes - not a write-in-progress chokidar's
|
|
88
109
|
// awaitWriteFinish can wait out, but a real (if temporary) empty file on disk.
|
|
@@ -93,64 +114,12 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
|
|
|
93
114
|
failedFiles.delete(file);
|
|
94
115
|
return;
|
|
95
116
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
// no parallelism, only scheduling. The plugins defer their async work into
|
|
99
|
-
// opts.promises rather than awaiting in a visitor, which is what makes sync viable.
|
|
100
|
-
const babelStart = performance.now();
|
|
101
|
-
const result = babelTransformFileSync(file, config);
|
|
102
|
-
tally('babel transform', performance.now() - babelStart);
|
|
103
|
-
if (result === null) throw new TungstenError(`Err: babel transform on file ${file} returned null`);
|
|
104
|
-
const {
|
|
105
|
-
code
|
|
106
|
-
} = result;
|
|
107
|
-
if (code === null || code === undefined) {
|
|
108
|
-
throw new TungstenError(`Err: code from babel transform on file ${file} was null or undefined: ${typeof code}`);
|
|
109
|
-
}
|
|
110
|
-
// tsc's incremental watch can, for one transient pass right after a save, emit
|
|
111
|
-
// `export {};` for a file that previously had real exports - its own convention
|
|
112
|
-
// for "this module has nothing to export", produced here as a self-correcting
|
|
113
|
-
// glitch rather than a real edit (confirmed via tsc's own transient
|
|
114
|
-
// "has no exported member" watch error). Quarantine it behind a timer rather than
|
|
115
|
-
// overwrite the last-good compiled output immediately: tsc's follow-up pass moments
|
|
116
|
-
// later normally retriggers this watcher with the real content, cancelling the
|
|
117
|
-
// quarantine below. But if nothing ever corrects it (a genuine edit really does
|
|
118
|
-
// remove every export), accept the quarantined content once the grace period lapses
|
|
119
|
-
// instead of hiding it forever.
|
|
120
|
-
if (code.trim() === 'export {};' && fs.existsSync(dest)) {
|
|
121
|
-
const previousCode = fs.readFileSync(dest, 'utf8');
|
|
122
|
-
if (previousCode.trim() !== 'export {};' && previousCode.trim() !== '') {
|
|
123
|
-
if (!pendingExportWipes.has(file)) {
|
|
124
|
-
const timer = setTimeout(() => {
|
|
125
|
-
void acceptQuarantinedExportWipe(file);
|
|
126
|
-
}, exportWipeGraceMs);
|
|
127
|
-
pendingExportWipes.set(file, {
|
|
128
|
-
dest,
|
|
129
|
-
code,
|
|
130
|
-
timer
|
|
131
|
-
});
|
|
132
|
-
} else {
|
|
133
|
-
// keep the original timer (grace period counts from the first sighting),
|
|
134
|
-
// just refresh the content that'll be written if it elapses
|
|
135
|
-
const pending = pendingExportWipes.get(file);
|
|
136
|
-
if (pending !== undefined) pending.code = code;
|
|
137
|
-
}
|
|
138
|
-
failedFiles.delete(file);
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
117
|
+
if (client) {
|
|
118
|
+
transformTo(file, config, join(buildCodeLocation, outputRel(file)), 'babel transform', true);
|
|
141
119
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
if (pendingWipe !== undefined) {
|
|
145
|
-
clearTimeout(pendingWipe.timer);
|
|
146
|
-
pendingExportWipes.delete(file);
|
|
120
|
+
if (raw) {
|
|
121
|
+
transformTo(file, rawConfig, join(rawBuildLocation, outputRel(file)), 'babel transform (raw)', false);
|
|
147
122
|
}
|
|
148
|
-
await fsPromises.mkdir(dirname(dest), {
|
|
149
|
-
recursive: true
|
|
150
|
-
});
|
|
151
|
-
//// Using the sync version here, because the promise version keeps bugging out - node bug?
|
|
152
|
-
//await fsPromises.writeFile(dest, code)
|
|
153
|
-
fs.writeFileSync(dest, code);
|
|
154
123
|
failedFiles.delete(file);
|
|
155
124
|
} catch (e) {
|
|
156
125
|
failedFiles.add(file);
|
|
@@ -159,28 +128,84 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
|
|
|
159
128
|
throw e;
|
|
160
129
|
}
|
|
161
130
|
}
|
|
131
|
+
// One pipeline's transform and write. Sync, so it can be tallied exactly - nothing else runs
|
|
132
|
+
// during it. Babel's work is cpu-bound on one thread either way, so the async API's 291
|
|
133
|
+
// concurrent calls bought no parallelism, only scheduling. The plugins defer their async work
|
|
134
|
+
// into opts.promises rather than awaiting in a visitor, which is what makes sync viable.
|
|
135
|
+
function transformTo(file, babelConfig, dest, tallyName, guardExportWipe) {
|
|
136
|
+
const result = tallied(tallyName, () => babelTransformFileSync(file, babelConfig));
|
|
137
|
+
if (result === null) throw new TungstenError(`Err: babel transform on file ${file} returned null`);
|
|
138
|
+
const {
|
|
139
|
+
code
|
|
140
|
+
} = result;
|
|
141
|
+
if (code === null || code === undefined) {
|
|
142
|
+
throw new TungstenError(`Err: code from babel transform on file ${file} was null or undefined: ${typeof code}`);
|
|
143
|
+
}
|
|
144
|
+
// tsc's incremental watch can, for one transient pass right after a save, emit
|
|
145
|
+
// `export {};` for a file that previously had real exports - its own convention
|
|
146
|
+
// for "this module has nothing to export", produced here as a self-correcting
|
|
147
|
+
// glitch rather than a real edit (confirmed via tsc's own transient
|
|
148
|
+
// "has no exported member" watch error). Quarantine it behind a timer rather than
|
|
149
|
+
// overwrite the last-good compiled output immediately: tsc's follow-up pass moments
|
|
150
|
+
// later normally retriggers this watcher with the real content, cancelling the
|
|
151
|
+
// quarantine below. But if nothing ever corrects it (a genuine edit really does
|
|
152
|
+
// remove every export), accept the quarantined content once the grace period lapses
|
|
153
|
+
// instead of hiding it forever. The client tree's guard only - the raw tree is not served.
|
|
154
|
+
if (guardExportWipe && code.trim() === 'export {};' && fs.existsSync(dest)) {
|
|
155
|
+
const previousCode = fs.readFileSync(dest, 'utf8');
|
|
156
|
+
if (previousCode.trim() !== 'export {};' && previousCode.trim() !== '') {
|
|
157
|
+
if (!pendingExportWipes.has(file)) {
|
|
158
|
+
const timer = setTimeout(() => {
|
|
159
|
+
void acceptQuarantinedExportWipe(file);
|
|
160
|
+
}, exportWipeGraceMs);
|
|
161
|
+
pendingExportWipes.set(file, {
|
|
162
|
+
dest,
|
|
163
|
+
code,
|
|
164
|
+
timer
|
|
165
|
+
});
|
|
166
|
+
} else {
|
|
167
|
+
// keep the original timer (grace period counts from the first sighting),
|
|
168
|
+
// just refresh the content that'll be written if it elapses
|
|
169
|
+
const pending = pendingExportWipes.get(file);
|
|
170
|
+
if (pending !== undefined) pending.code = code;
|
|
171
|
+
}
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
// real content arrived - cancel any quarantine still pending for this file
|
|
176
|
+
if (guardExportWipe) {
|
|
177
|
+
const pendingWipe = pendingExportWipes.get(file);
|
|
178
|
+
if (pendingWipe !== undefined) {
|
|
179
|
+
clearTimeout(pendingWipe.timer);
|
|
180
|
+
pendingExportWipes.delete(file);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
fs.mkdirSync(dirname(dest), {
|
|
184
|
+
recursive: true
|
|
185
|
+
});
|
|
186
|
+
//// Using the sync version here, because the promise version keeps bugging out - node bug?
|
|
187
|
+
fs.writeFileSync(dest, code);
|
|
188
|
+
}
|
|
162
189
|
async function deleteTransformedFile(file) {
|
|
163
|
-
let rel = file.slice(codeLocationLength);
|
|
164
|
-
if (rel.endsWith('.jsx')) rel = rel.slice(0, -1);
|
|
165
|
-
const dest = join(buildCodeLocation, rel);
|
|
166
190
|
const pendingWipe = pendingExportWipes.get(file);
|
|
167
191
|
if (pendingWipe !== undefined) {
|
|
168
192
|
clearTimeout(pendingWipe.timer);
|
|
169
193
|
pendingExportWipes.delete(file);
|
|
170
194
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
195
|
+
// whichever trees hold it
|
|
196
|
+
for (const dest of [join(buildCodeLocation, outputRel(file)), join(rawBuildLocation, outputRel(file))]) {
|
|
197
|
+
try {
|
|
198
|
+
await fsPromises.unlink(dest);
|
|
199
|
+
} catch (error) {
|
|
200
|
+
const fileError = error;
|
|
201
|
+
if (fileError.code !== 'ENOENT') throw error;
|
|
202
|
+
}
|
|
176
203
|
}
|
|
177
204
|
failedFiles.delete(file);
|
|
178
205
|
}
|
|
179
206
|
async function copyFile(file) {
|
|
180
207
|
try {
|
|
181
|
-
|
|
182
|
-
if (rel.endsWith('.jsx')) rel = rel.slice(0, -1);
|
|
183
|
-
const dest = join(buildCodeLocation, rel);
|
|
208
|
+
const dest = join(buildCodeLocation, outputRel(file));
|
|
184
209
|
await fsPromises.mkdir(dirname(dest), {
|
|
185
210
|
recursive: true
|
|
186
211
|
});
|
|
@@ -194,9 +219,7 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
|
|
|
194
219
|
}
|
|
195
220
|
async function deleteFile(file) {
|
|
196
221
|
try {
|
|
197
|
-
|
|
198
|
-
if (rel.endsWith('.jsx')) rel = rel.slice(0, -1);
|
|
199
|
-
const dest = join(buildCodeLocation, rel);
|
|
222
|
+
const dest = join(buildCodeLocation, outputRel(file));
|
|
200
223
|
await fsPromises.unlink(dest);
|
|
201
224
|
} catch (e) {
|
|
202
225
|
cliError(`Tungsten: Error deleting file ${file}`);
|
|
@@ -205,11 +228,12 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
|
|
|
205
228
|
}
|
|
206
229
|
}
|
|
207
230
|
// get a list of files
|
|
208
|
-
const watchGlob = slash(`${codeLocation}/**/*.js{,
|
|
231
|
+
const watchGlob = slash(`${codeLocation}/**/*.{js,jsx${typescript ? ',ts,tsx' : ''}}`);
|
|
209
232
|
// typed rather than inferred from the pushes: it is captured by a closure below, which stops
|
|
210
233
|
// typescript widening it from the pushes
|
|
211
234
|
const ignored = [];
|
|
212
235
|
ignored.push(slash(`${buildLocation}/**`));
|
|
236
|
+
if (typescript) ignored.push(slash(`${codeLocation}/**/*.d.ts`));
|
|
213
237
|
if (appConfig.ignoreDirs !== undefined && appConfig.ignoreDirs !== '') {
|
|
214
238
|
const ignoreDirs = typeof appConfig.ignoreDirs === 'string' ? [appConfig.ignoreDirs] : appConfig.ignoreDirs;
|
|
215
239
|
ignored.push(...ignoreDirs.map(folder => slash(`${codeLocation}/${folder}/**`)));
|
|
@@ -235,6 +259,35 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
|
|
|
235
259
|
}
|
|
236
260
|
}
|
|
237
261
|
if (appConfig.exclude !== undefined) ignored.push(slash(`${codeLocation}/${appConfig.exclude}`));
|
|
262
|
+
// Which sources each pipeline compiles. Unset, client is everything and raw is nothing; a file
|
|
263
|
+
// may be in both. Dirs and patterns are relative to codeDir. The ignores are not applied
|
|
264
|
+
// here - every file that reaches isClient/isRaw has already passed them, in the initial glob
|
|
265
|
+
// or in the watcher - so "client minus ignores" holds. Sets rather than matchers, refreshed on
|
|
266
|
+
// the watcher's `add`, like skipPackageCompilationFiles.
|
|
267
|
+
const sourceExtensions = `*.{js,jsx${typescript ? ',ts,tsx' : ''}}`;
|
|
268
|
+
function selectionGlobs(dirs, patterns) {
|
|
269
|
+
if (dirs === undefined && patterns === undefined) return null;
|
|
270
|
+
const list = value => value === undefined || value === '' ? [] : typeof value === 'string' ? [value] : value;
|
|
271
|
+
return [...list(dirs).map(dir => `${dir}/**/${sourceExtensions}`), ...list(patterns)];
|
|
272
|
+
}
|
|
273
|
+
const clientSelection = selectionGlobs(appConfig.clientDirs, appConfig.clientPatterns);
|
|
274
|
+
const rawSelection = selectionGlobs(appConfig.rawDirs, appConfig.rawPatterns);
|
|
275
|
+
let clientFiles = null;
|
|
276
|
+
let rawFiles = new Set();
|
|
277
|
+
async function selectedFiles(selection) {
|
|
278
|
+
const files = await globby(selection, {
|
|
279
|
+
cwd: codeLocation,
|
|
280
|
+
absolute: true
|
|
281
|
+
});
|
|
282
|
+
return new Set(files.map(file => slash(file)));
|
|
283
|
+
}
|
|
284
|
+
async function refreshSelections() {
|
|
285
|
+
clientFiles = clientSelection === null ? null : await selectedFiles(clientSelection);
|
|
286
|
+
rawFiles = rawSelection === null ? new Set() : await selectedFiles(rawSelection);
|
|
287
|
+
}
|
|
288
|
+
const isClient = file => clientFiles === null || clientFiles.has(file);
|
|
289
|
+
const isRaw = file => rawFiles.has(file);
|
|
290
|
+
await refreshSelections();
|
|
238
291
|
//console.log('appConfig', appConfig)
|
|
239
292
|
//console.log('ignored', ignored)
|
|
240
293
|
//cliWarn(watchGlob)
|
|
@@ -276,7 +329,7 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
|
|
|
276
329
|
recursive: true
|
|
277
330
|
});
|
|
278
331
|
}
|
|
279
|
-
fs.writeFileSync(dependencyGraphLocation, `export const graph = ${serializeJavascript(dependencyGraph)}`);
|
|
332
|
+
fs.writeFileSync(dependencyGraphLocation, `export const version = ${serializeJavascript(frameworkVersion)}\n` + `export const graph = ${serializeJavascript(dependencyGraph)}`);
|
|
280
333
|
}
|
|
281
334
|
async function acceptQuarantinedExportWipe(file) {
|
|
282
335
|
const pending = pendingExportWipes.get(file);
|
|
@@ -299,7 +352,8 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
|
|
|
299
352
|
}
|
|
300
353
|
await options.onCycleComplete?.({
|
|
301
354
|
success,
|
|
302
|
-
file
|
|
355
|
+
file,
|
|
356
|
+
client: true
|
|
303
357
|
});
|
|
304
358
|
}
|
|
305
359
|
if (!watch) {
|
|
@@ -337,7 +391,10 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
|
|
|
337
391
|
if (event === 'unlink') {
|
|
338
392
|
await deleteTransformedFile(file);
|
|
339
393
|
} else {
|
|
340
|
-
if (event === 'add')
|
|
394
|
+
if (event === 'add') {
|
|
395
|
+
await refreshSkipPackageCompilationFiles();
|
|
396
|
+
await refreshSelections();
|
|
397
|
+
}
|
|
341
398
|
await transformFile(file);
|
|
342
399
|
}
|
|
343
400
|
const failures = await settleDeferredWork();
|
|
@@ -348,7 +405,8 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
|
|
|
348
405
|
}
|
|
349
406
|
await options.onCycleComplete?.({
|
|
350
407
|
success,
|
|
351
|
-
file
|
|
408
|
+
file,
|
|
409
|
+
client: isClient(file)
|
|
352
410
|
});
|
|
353
411
|
}).catch(error => {
|
|
354
412
|
cliError('Tungsten: Error completing JavaScript watch cycle');
|
|
@@ -5,10 +5,10 @@ import { pathToFileURL } from 'url';
|
|
|
5
5
|
import { promises as fsPromises, utimesSync } from 'fs';
|
|
6
6
|
import * as sass from 'sass';
|
|
7
7
|
import { globby } from 'globby';
|
|
8
|
-
import { staticFolder } from
|
|
9
|
-
import { cliError, cliOut } from
|
|
10
|
-
import { throwError } from
|
|
11
|
-
import { resolveSassImport, resolveScssImport } from
|
|
8
|
+
import { staticFolder } from '../settings.js';
|
|
9
|
+
import { cliError, cliOut } from '../cliOutput.js'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
10
|
+
import { throwError } from '../throwError.js';
|
|
11
|
+
import { resolveSassImport, resolveScssImport } from './resolveSassScssImports.js';
|
|
12
12
|
function debug(...texts) {
|
|
13
13
|
//console.log(...texts)
|
|
14
14
|
}
|
|
@@ -2,5 +2,5 @@ import type { CompilationInfo } from './CompilationInfo.js';
|
|
|
2
2
|
import type { FrameworkConfigComplete } from '../FrameworkConfig.js';
|
|
3
3
|
import type { Mode } from '../Mode.js';
|
|
4
4
|
import { type TimeProfiler } from '../timeProfiler.js';
|
|
5
|
-
export declare function compileUserApp(projectDir: string, appConfig: FrameworkConfigComplete, mode: Mode, profiler?: TimeProfiler, quiet?: boolean, tests?: boolean): Promise<CompilationInfo>;
|
|
5
|
+
export declare function compileUserApp(projectDir: string, appConfig: FrameworkConfigComplete, mode: Mode, profiler?: TimeProfiler, quiet?: boolean, tests?: boolean, fresh?: boolean): Promise<CompilationInfo>;
|
|
6
6
|
//# sourceMappingURL=compileUserApp.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compileUserApp.d.ts","sourceRoot":"","sources":["../../src/build/compileUserApp.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAWtC,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAI1E,wBAAsB,cAAc,CAChC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,uBAAuB,EAAE,IAAI,EAAE,IAAI,EAClE,QAAQ,GAAE,YAAwC,EAAE,KAAK,UAAQ,EAAE,KAAK,UAAQ,
|
|
1
|
+
{"version":3,"file":"compileUserApp.d.ts","sourceRoot":"","sources":["../../src/build/compileUserApp.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAWtC,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAI1E,wBAAsB,cAAc,CAChC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,uBAAuB,EAAE,IAAI,EAAE,IAAI,EAClE,QAAQ,GAAE,YAAwC,EAAE,KAAK,UAAQ,EAAE,KAAK,UAAQ,EAAE,KAAK,UAAQ,GAChG,OAAO,CAAC,eAAe,CAAC,CAgF1B"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { join } from 'path';
|
|
2
|
-
import { compileJavascript } from
|
|
3
|
-
import { compileStyles } from
|
|
4
|
-
import { copyAssets } from
|
|
5
|
-
import { copyPublicFiles } from
|
|
6
|
-
import { buildCodeSubPath, bundleFolder, devBuildOuterFolder, frameworkCssFile, frameworkCssFolder, prodBuildFolder } from
|
|
7
|
-
import { combineComponentCss } from
|
|
8
|
-
import { writeFrameworkCss } from
|
|
9
|
-
import { emitReloadEvent } from
|
|
10
|
-
import { createTimeProfiler } from
|
|
2
|
+
import { compileJavascript } from './compileJavascript.js';
|
|
3
|
+
import { compileStyles } from './compileStyles.js';
|
|
4
|
+
import { copyAssets } from './copyAssets.js';
|
|
5
|
+
import { copyPublicFiles } from './copyPublicFiles.js';
|
|
6
|
+
import { buildCodeSubPath, bundleFolder, devBuildOuterFolder, frameworkCssFile, frameworkCssFolder, prodBuildFolder } from '../settings.js';
|
|
7
|
+
import { combineComponentCss } from './combineComponentCss.js';
|
|
8
|
+
import { writeFrameworkCss } from './frameworkStylesheets.js';
|
|
9
|
+
import { emitReloadEvent } from '../hmr/liveReloadHub.js';
|
|
10
|
+
import { createTimeProfiler } from '../timeProfiler.js';
|
|
11
11
|
//import { compileEnv } from './compileEnv.js'
|
|
12
|
-
export async function compileUserApp(projectDir, appConfig, mode, profiler = createTimeProfiler(false), quiet = false, tests = false) {
|
|
12
|
+
export async function compileUserApp(projectDir, appConfig, mode, profiler = createTimeProfiler(false), quiet = false, tests = false, fresh = false) {
|
|
13
13
|
const codeLocation = join(projectDir, appConfig.codeDir);
|
|
14
14
|
const relSourceDir = appConfig.sourceDir !== undefined && appConfig.sourceDir !== '' ? appConfig.sourceDir : appConfig.codeDir;
|
|
15
15
|
const sourceLocation = join(projectDir, relSourceDir);
|
|
@@ -23,13 +23,16 @@ export async function compileUserApp(projectDir, appConfig, mode, profiler = cre
|
|
|
23
23
|
const compileJavascriptPromise = profiler.timeProfileAsync('compile javascript', () => compileJavascript(projectDir, appConfig, codeLocation, sourceLocation, styleImportBase, buildLocation, buildCodeLocation, mode, watch, mode === 'dev' ? {
|
|
24
24
|
quiet,
|
|
25
25
|
tests,
|
|
26
|
+
fresh,
|
|
26
27
|
hmr: appConfig.hmr === true,
|
|
28
|
+
// a raw-only file (server code) has nothing for the browser to reload
|
|
27
29
|
onCycleComplete: cycle => {
|
|
28
|
-
if (cycle.success) emitReloadEvent('js', cycle.file);
|
|
30
|
+
if (cycle.success && cycle.client !== false) emitReloadEvent('js', cycle.file);
|
|
29
31
|
}
|
|
30
32
|
} : {
|
|
31
33
|
quiet,
|
|
32
|
-
tests
|
|
34
|
+
tests,
|
|
35
|
+
fresh
|
|
33
36
|
}));
|
|
34
37
|
//const compileEnvPromise = compileEnv(projectDir, appConfig, codeLocation, buildLocation, mode)
|
|
35
38
|
const compileStylesPromise = profiler.timeProfileAsync('compile styles', () => compileStyles(projectDir, appConfig, styleImportBase, buildLocation, watch, mode === 'dev' ? () => emitReloadEvent('css') : undefined, quiet));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type CompiledStyles = {
|
|
2
|
+
css: string;
|
|
3
|
+
dependencies: string[];
|
|
4
|
+
};
|
|
5
|
+
export declare function makeComponentStylesCache(cacheDir: string | undefined, fresh?: boolean): {
|
|
6
|
+
lookup(moduleName: string, language: string, rawStyles: string): CompiledStyles | undefined;
|
|
7
|
+
store(moduleName: string, language: string, rawStyles: string, compiled: CompiledStyles): void;
|
|
8
|
+
};
|
|
9
|
+
export type ComponentStylesCache = ReturnType<typeof makeComponentStylesCache>;
|
|
10
|
+
//# sourceMappingURL=componentStylesCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentStylesCache.d.ts","sourceRoot":"","sources":["../../src/build/componentStylesCache.ts"],"names":[],"mappings":"AAUA,MAAM,MAAM,cAAc,GAAG;IACzB,GAAG,EAAE,MAAM,CAAA;IAEX,YAAY,EAAE,MAAM,EAAE,CAAA;CACzB,CAAA;AAoBD,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,UAAQ;uBAKzD,MAAM,YAAY,MAAM,aAAa,MAAM,GAAG,cAAc,GAAG,SAAS;sBAezE,MAAM,YAAY,MAAM,aAAa,MAAM,YAAY,cAAc;EAY9F;AAED,MAAM,MAAM,oBAAoB,GAAG,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { createHash } from 'crypto';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
import { frameworkVersion } from './frameworkDestLocation.js';
|
|
5
|
+
const sha1 = data => createHash('sha1').update(data).digest('hex');
|
|
6
|
+
const blockHash = (language, rawStyles) => sha1(`${language}\0${rawStyles}`);
|
|
7
|
+
const fileHash = file => {
|
|
8
|
+
try {
|
|
9
|
+
return sha1(fs.readFileSync(file, 'utf8'));
|
|
10
|
+
} catch {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
// fresh: every lookup misses, so everything compiles from source and the records are all rewritten
|
|
15
|
+
export function makeComponentStylesCache(cacheDir, fresh = false) {
|
|
16
|
+
// `#` (the framework module prefix) is kept out of filenames, as the css manifest does
|
|
17
|
+
const recordFile = (dir, moduleName) => join(dir, `${moduleName.replaceAll('#', '')}.json`);
|
|
18
|
+
return {
|
|
19
|
+
lookup(moduleName, language, rawStyles) {
|
|
20
|
+
if (cacheDir === undefined || fresh) return undefined;
|
|
21
|
+
let record;
|
|
22
|
+
try {
|
|
23
|
+
record = JSON.parse(fs.readFileSync(recordFile(cacheDir, moduleName), 'utf8'));
|
|
24
|
+
} catch {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
if (record.version !== frameworkVersion || record.hash !== blockHash(language, rawStyles)) return undefined;
|
|
28
|
+
if (!Array.isArray(record.dependencies) || typeof record.css !== 'string') return undefined;
|
|
29
|
+
for (const dependency of record.dependencies) {
|
|
30
|
+
if (fileHash(dependency.file) !== dependency.hash) return undefined;
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
css: record.css,
|
|
34
|
+
dependencies: record.dependencies.map(dependency => dependency.file)
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
store(moduleName, language, rawStyles, compiled) {
|
|
38
|
+
if (cacheDir === undefined) return;
|
|
39
|
+
const record = {
|
|
40
|
+
version: frameworkVersion,
|
|
41
|
+
hash: blockHash(language, rawStyles),
|
|
42
|
+
css: compiled.css,
|
|
43
|
+
dependencies: compiled.dependencies.map(file => ({
|
|
44
|
+
file,
|
|
45
|
+
hash: fileHash(file) ?? ''
|
|
46
|
+
}))
|
|
47
|
+
};
|
|
48
|
+
fs.mkdirSync(cacheDir, {
|
|
49
|
+
recursive: true
|
|
50
|
+
});
|
|
51
|
+
fs.writeFileSync(recordFile(cacheDir, moduleName), JSON.stringify(record));
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
package/dist/build/copyAssets.js
CHANGED
|
@@ -3,7 +3,7 @@ import chokidar from 'chokidar';
|
|
|
3
3
|
import { join, dirname } from 'path';
|
|
4
4
|
import { promises as fsPromises } from 'fs';
|
|
5
5
|
import { globby } from 'globby';
|
|
6
|
-
import { cliOut } from
|
|
6
|
+
import { cliOut } from '../cliOutput.js';
|
|
7
7
|
async function copyFile(assetsLocation, targetLocation, filePathFull, event) {
|
|
8
8
|
const relFile = filePathFull.slice(assetsLocation.length + 1);
|
|
9
9
|
const target = join(targetLocation, relFile);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { existsSync, promises as fsPromises } from 'fs';
|
|
2
2
|
import { dirname, join } from 'path';
|
|
3
3
|
import { transformSync as babelTransformSync } from '@babel/core';
|
|
4
|
-
import { findProjectDir } from
|
|
5
|
-
import { devBuildOuterFolder, prodBuildFolder, packagesFolder } from
|
|
6
|
-
import { MakeBabelTransformDependencyImports } from
|
|
7
|
-
import { TungstenError } from
|
|
4
|
+
import { findProjectDir } from '../findProjectDir.js';
|
|
5
|
+
import { devBuildOuterFolder, prodBuildFolder, packagesFolder } from '../settings.js';
|
|
6
|
+
import { MakeBabelTransformDependencyImports } from '../babelPlugins/BabelTransformDependencyImportsOld.js';
|
|
7
|
+
import { TungstenError } from '../TungstenError.js';
|
|
8
8
|
import { cliWarn } from 'tungsten/cliOutput.js';
|
|
9
9
|
const frameworkDir = findProjectDir(import.meta.url);
|
|
10
10
|
// unused!
|
|
@@ -3,7 +3,7 @@ import chokidar from 'chokidar';
|
|
|
3
3
|
import { join, dirname } from 'path';
|
|
4
4
|
import { promises as fsPromises } from 'fs';
|
|
5
5
|
import { globby } from 'globby';
|
|
6
|
-
import { cliOut } from
|
|
6
|
+
import { cliOut } from '../cliOutput.js';
|
|
7
7
|
async function copyFile(assetsLocation, targetLocation, filePathFull, event) {
|
|
8
8
|
const relFile = filePathFull.slice(assetsLocation.length + 1);
|
|
9
9
|
const target = join(targetLocation, relFile);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { promises as fsPromises } from 'fs';
|
|
2
2
|
import { join } from 'path';
|
|
3
|
-
import { buildCodeSubPath, devBuildOuterFolder, prodBuildFolder, clientFolder, frameworkDistFolder, frameworkClientFolder } from
|
|
4
|
-
import { fixExtension } from
|
|
5
|
-
import { findProjectDir } from
|
|
3
|
+
import { buildCodeSubPath, devBuildOuterFolder, prodBuildFolder, clientFolder, frameworkDistFolder, frameworkClientFolder } from '../settings.js';
|
|
4
|
+
import { fixExtension } from '../fixExtension.js';
|
|
5
|
+
import { findProjectDir } from '../findProjectDir.js';
|
|
6
6
|
export async function createClientFiles(config, mode, buildLocation) {
|
|
7
7
|
//console.log('creating entry file')
|
|
8
8
|
const specificBuildFolder = buildLocation ?? join(process.cwd(), mode === 'dev' ? devBuildOuterFolder : prodBuildFolder);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { promises as fsPromises } from 'fs';
|
|
2
2
|
import { join, dirname } from 'path';
|
|
3
|
-
import { devBuildOuterFolder, prodBuildFolder } from
|
|
4
|
-
import { TungstenError } from
|
|
3
|
+
import { devBuildOuterFolder, prodBuildFolder } from '../settings.js';
|
|
4
|
+
import { TungstenError } from '../TungstenError.js';
|
|
5
5
|
export async function createInstanceConfigFile(config, mode, buildLocation) {
|
|
6
6
|
//console.log('creating app config')
|
|
7
7
|
const specificBuildFolder = buildLocation ?? join(process.cwd(), mode === 'dev' ? devBuildOuterFolder : prodBuildFolder);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createPackageVirtualFileSystem } from
|
|
1
|
+
import { createPackageVirtualFileSystem } from './createPackageVirtualFileSystem.js';
|
|
2
2
|
// pretty sure we aren't using this now
|
|
3
3
|
export function createPackageVirtualFileSystems(packages) {
|
|
4
4
|
for (const p of Object.values(packages)) {
|
package/dist/build/devBundle.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { join } from 'path';
|
|
2
|
-
import { getFrameworkDir } from
|
|
3
|
-
import { devBuildOuterFolder, frameworkDistFolder } from
|
|
4
|
-
import { spawnShellCommand } from
|
|
5
|
-
import { cliError, cliOut } from
|
|
6
|
-
import { frameworkDestLocation } from
|
|
2
|
+
import { getFrameworkDir } from '../getFrameworkDir.js';
|
|
3
|
+
import { devBuildOuterFolder, frameworkDistFolder } from '../settings.js';
|
|
4
|
+
import { spawnShellCommand } from '../spawnShellCommand.js';
|
|
5
|
+
import { cliError, cliOut } from '../cliOutput.js';
|
|
6
|
+
import { frameworkDestLocation } from './frameworkDestLocation.js';
|
|
7
7
|
export async function devBundle() {
|
|
8
8
|
return new Promise((resolve, reject) => {
|
|
9
9
|
cliOut('Creating dev bundle');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devBundle.rollup.config.d.ts","sourceRoot":"","sources":["../../src/build/devBundle.rollup.config.ts"],"names":[],"mappings":"AAUA,KAAK,YAAY,GAAG;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACrB,CAAA;AAED,QAAA,MAAM,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"devBundle.rollup.config.d.ts","sourceRoot":"","sources":["../../src/build/devBundle.rollup.config.ts"],"names":[],"mappings":"AAUA,KAAK,YAAY,GAAG;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACrB,CAAA;AAED,QAAA,MAAM,YAAY,EAAE,YAiBnB,CAAA;AAED,eAAe,YAAY,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frameworkDestLocation.d.ts","sourceRoot":"","sources":["../../src/build/frameworkDestLocation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"frameworkDestLocation.d.ts","sourceRoot":"","sources":["../../src/build/frameworkDestLocation.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,gBAAgB,EAAE,MAA4B,CAAA;AAC3D,eAAO,MAAM,qBAAqB,QAAyE,CAAA"}
|