@ttsc/strip 0.32.1 → 0.33.0

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.
Files changed (2) hide show
  1. package/driver/config.go +25 -2
  2. package/package.json +1 -1
package/driver/config.go CHANGED
@@ -5,14 +5,17 @@ import (
5
5
  "context"
6
6
  "crypto/sha256"
7
7
  "encoding/json"
8
+ "errors"
8
9
  "fmt"
9
10
  "os"
10
11
  "os/exec"
11
12
  "path/filepath"
12
13
  "runtime"
13
14
  "strings"
15
+ "syscall"
14
16
 
15
17
  "github.com/samchon/ttsc/packages/ttsc/driver"
18
+ "github.com/samchon/ttsc/packages/ttsc/driver/configloaderscratch"
16
19
  "github.com/samchon/ttsc/packages/ttsc/driver/resolutioninputs"
17
20
  "github.com/samchon/ttsc/packages/ttsc/driver/windowsjunction"
18
21
  )
@@ -494,9 +497,10 @@ declare const process: {
494
497
  //
495
498
  // Both tools this spawns — the launcher and the compiler handed to it — are
496
499
  // resolved from the project rather than from the process environment alone;
497
- // see stripConfigToolAnchors.
500
+ // see stripConfigToolAnchors. An already-open identity store can hold the
501
+ // loader on a cross-volume TEMP setup without moving the config directory.
498
502
  func loadStripTypeScriptConfigFileWithInputs(location, resolutionRoot string) (stripLoadedConfig, error) {
499
- tempDir, err := os.MkdirTemp(stripLoaderTempBase(location, os.TempDir()), "ttsc-strip-config-")
503
+ tempDir, err := createStripConfigLoaderTempDir(location, os.TempDir(), os.Getenv("TTSC_NATIVE_PLUGIN_RECORD_ROOT"))
500
504
  if err != nil {
501
505
  return stripLoadedConfig{}, fmt.Errorf("@ttsc/strip: create config loader tempdir: %w", err)
502
506
  }
@@ -569,6 +573,25 @@ func loadStripTypeScriptConfigFileWithInputs(location, resolutionRoot string) (s
569
573
  return loaded, nil
570
574
  }
571
575
 
576
+ // createStripConfigLoaderTempDir uses this invocation's existing identity
577
+ // directory when it is safe for the config; otherwise it preserves the
578
+ // historical loader base. Expected filesystem refusal of the preferred base
579
+ // also falls back, while unexpected errors remain visible to the caller.
580
+ func createStripConfigLoaderTempDir(location, systemTemp, recordRoot string) (string, error) {
581
+ preferred := configloaderscratch.IdentityTempBase(location, systemTemp, recordRoot)
582
+ var tempDir string
583
+ var err error
584
+ if preferred != "" {
585
+ tempDir, err = os.MkdirTemp(preferred, "ttsc-strip-config-")
586
+ }
587
+ if preferred == "" || (err != nil &&
588
+ (os.IsPermission(err) || os.IsNotExist(err) ||
589
+ errors.Is(err, syscall.ENOTDIR) || errors.Is(err, syscall.EROFS))) {
590
+ tempDir, err = os.MkdirTemp(stripLoaderTempBase(location, systemTemp), "ttsc-strip-config-")
591
+ }
592
+ return tempDir, err
593
+ }
594
+
572
595
  // stripTypeScriptLoaderTsconfig generates the JSON content of the ephemeral
573
596
  // tsconfig used by the loader script.
574
597
  func stripTypeScriptLoaderTsconfig(loader, location, outDir string) string {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttsc/strip",
3
- "version": "0.32.1",
3
+ "version": "0.33.0",
4
4
  "description": "First-party ttsc plugin that removes configured calls and statements from emitted JavaScript.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",