@locuschain/lib 0.1.40 → 0.2.1

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.
@@ -39,6 +39,17 @@ define(['module', 'exports', 'node:fs', 'node:path', 'node:url'], (function (mod
39
39
  // 이 모듈은 lib 패키지의 dist/vite-plugin/index.{esm.js|cjs.cjs} 로 빌드된다.
40
40
  // 따라서 `../autogen/wasm/` 은 dist/autogen/wasm/ 을 가리킨다 (rollup-plugin-copy 로 동봉됨).
41
41
  const WASM_DIR = node_url.fileURLToPath(new URL('../autogen/wasm/', new URL(module.uri, document.baseURI).href));
42
+ // dist/vite-plugin/index.esm.js 기준으로 ../../package.json = lib/package.json.
43
+ // lib 자기 자신의 패키지 이름과 모든 export subpath 를 동적으로 추출해서
44
+ // Vite dev 의 optimizeDeps 사전 번들링에서 제외한다 (아래 config 훅 참조).
45
+ const PKG_PATH = node_url.fileURLToPath(new URL('../../package.json', new URL(module.uri, document.baseURI).href));
46
+ const PKG = JSON.parse(fs.readFileSync(PKG_PATH, 'utf-8'));
47
+ const OPTIMIZE_DEPS_EXCLUDE = (() => {
48
+ var _a;
49
+ const name = PKG.name;
50
+ const keys = Object.keys((_a = PKG.exports) !== null && _a !== void 0 ? _a : { '.': null });
51
+ return keys.map(k => (k === '.' ? name : `${name}${k.slice(1)}`));
52
+ })();
42
53
  // lib 코드(자체 패키지 또는 npm link 된 로컬 경로) 안에서만 transform 한다.
43
54
  const LIB_ID_PATTERN = /(?:@locuschain[/\\]lib|locuschain-js[/\\]packages[/\\]lib)[/\\]dist[/\\]/;
44
55
  // 두 가지 패턴 모두 매칭:
@@ -61,6 +72,19 @@ define(['module', 'exports', 'node:fs', 'node:path', 'node:url'], (function (mod
61
72
  return {
62
73
  name: 'locuschain-wasm',
63
74
  enforce: 'pre',
75
+ // Vite dev 의 의존성 사전 번들링(.vite/deps/) 은 esbuild 로 처리돼 일반 plugin transform 훅을
76
+ // 건너뛴다. lib 이 사전 번들링되면 `new URL("../autogen/wasm/<name>", import.meta.url)` 가
77
+ // 치환되지 않은 채 `.vite/deps/` 안의 파일에서 그대로 실행되고, 상대경로가
78
+ // `.vite/autogen/wasm/<name>` 로 풀려 404 가 난다.
79
+ // lib 의 모든 export subpath 를 exclude 에 넣어 사전 번들링을 막는다.
80
+ // 사용자가 wxt.config.ts 에 별도 exclude 를 설정하지 않아도 자동 적용된다.
81
+ config() {
82
+ return {
83
+ optimizeDeps: {
84
+ exclude: OPTIMIZE_DEPS_EXCLUDE
85
+ }
86
+ };
87
+ },
64
88
  configResolved(config) {
65
89
  var _a, _b;
66
90
  isServe = config.command === 'serve';
@@ -46,6 +46,17 @@ const WASM_FILES = [
46
46
  // 이 모듈은 lib 패키지의 dist/vite-plugin/index.{esm.js|cjs.cjs} 로 빌드된다.
47
47
  // 따라서 `../autogen/wasm/` 은 dist/autogen/wasm/ 을 가리킨다 (rollup-plugin-copy 로 동봉됨).
48
48
  const WASM_DIR = node_url.fileURLToPath(new URL('../autogen/wasm/', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('vite-plugin/index.cjs.cjs', document.baseURI).href))));
49
+ // dist/vite-plugin/index.esm.js 기준으로 ../../package.json = lib/package.json.
50
+ // lib 자기 자신의 패키지 이름과 모든 export subpath 를 동적으로 추출해서
51
+ // Vite dev 의 optimizeDeps 사전 번들링에서 제외한다 (아래 config 훅 참조).
52
+ const PKG_PATH = node_url.fileURLToPath(new URL('../../package.json', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('vite-plugin/index.cjs.cjs', document.baseURI).href))));
53
+ const PKG = JSON.parse(fs.readFileSync(PKG_PATH, 'utf-8'));
54
+ const OPTIMIZE_DEPS_EXCLUDE = (() => {
55
+ var _a;
56
+ const name = PKG.name;
57
+ const keys = Object.keys((_a = PKG.exports) !== null && _a !== void 0 ? _a : { '.': null });
58
+ return keys.map(k => (k === '.' ? name : `${name}${k.slice(1)}`));
59
+ })();
49
60
  // lib 코드(자체 패키지 또는 npm link 된 로컬 경로) 안에서만 transform 한다.
50
61
  const LIB_ID_PATTERN = /(?:@locuschain[/\\]lib|locuschain-js[/\\]packages[/\\]lib)[/\\]dist[/\\]/;
51
62
  // 두 가지 패턴 모두 매칭:
@@ -68,6 +79,19 @@ function locusWasmPlugin(opts = {}) {
68
79
  return {
69
80
  name: 'locuschain-wasm',
70
81
  enforce: 'pre',
82
+ // Vite dev 의 의존성 사전 번들링(.vite/deps/) 은 esbuild 로 처리돼 일반 plugin transform 훅을
83
+ // 건너뛴다. lib 이 사전 번들링되면 `new URL("../autogen/wasm/<name>", import.meta.url)` 가
84
+ // 치환되지 않은 채 `.vite/deps/` 안의 파일에서 그대로 실행되고, 상대경로가
85
+ // `.vite/autogen/wasm/<name>` 로 풀려 404 가 난다.
86
+ // lib 의 모든 export subpath 를 exclude 에 넣어 사전 번들링을 막는다.
87
+ // 사용자가 wxt.config.ts 에 별도 exclude 를 설정하지 않아도 자동 적용된다.
88
+ config() {
89
+ return {
90
+ optimizeDeps: {
91
+ exclude: OPTIMIZE_DEPS_EXCLUDE
92
+ }
93
+ };
94
+ },
71
95
  configResolved(config) {
72
96
  var _a, _b;
73
97
  isServe = config.command === 'serve';
@@ -41,6 +41,17 @@ const WASM_FILES = [
41
41
  // 이 모듈은 lib 패키지의 dist/vite-plugin/index.{esm.js|cjs.cjs} 로 빌드된다.
42
42
  // 따라서 `../autogen/wasm/` 은 dist/autogen/wasm/ 을 가리킨다 (rollup-plugin-copy 로 동봉됨).
43
43
  const WASM_DIR = fileURLToPath(new URL('../autogen/wasm/', import.meta.url));
44
+ // dist/vite-plugin/index.esm.js 기준으로 ../../package.json = lib/package.json.
45
+ // lib 자기 자신의 패키지 이름과 모든 export subpath 를 동적으로 추출해서
46
+ // Vite dev 의 optimizeDeps 사전 번들링에서 제외한다 (아래 config 훅 참조).
47
+ const PKG_PATH = fileURLToPath(new URL('../../package.json', import.meta.url));
48
+ const PKG = JSON.parse(fs.readFileSync(PKG_PATH, 'utf-8'));
49
+ const OPTIMIZE_DEPS_EXCLUDE = (() => {
50
+ var _a;
51
+ const name = PKG.name;
52
+ const keys = Object.keys((_a = PKG.exports) !== null && _a !== void 0 ? _a : { '.': null });
53
+ return keys.map(k => (k === '.' ? name : `${name}${k.slice(1)}`));
54
+ })();
44
55
  // lib 코드(자체 패키지 또는 npm link 된 로컬 경로) 안에서만 transform 한다.
45
56
  const LIB_ID_PATTERN = /(?:@locuschain[/\\]lib|locuschain-js[/\\]packages[/\\]lib)[/\\]dist[/\\]/;
46
57
  // 두 가지 패턴 모두 매칭:
@@ -63,6 +74,19 @@ function locusWasmPlugin(opts = {}) {
63
74
  return {
64
75
  name: 'locuschain-wasm',
65
76
  enforce: 'pre',
77
+ // Vite dev 의 의존성 사전 번들링(.vite/deps/) 은 esbuild 로 처리돼 일반 plugin transform 훅을
78
+ // 건너뛴다. lib 이 사전 번들링되면 `new URL("../autogen/wasm/<name>", import.meta.url)` 가
79
+ // 치환되지 않은 채 `.vite/deps/` 안의 파일에서 그대로 실행되고, 상대경로가
80
+ // `.vite/autogen/wasm/<name>` 로 풀려 404 가 난다.
81
+ // lib 의 모든 export subpath 를 exclude 에 넣어 사전 번들링을 막는다.
82
+ // 사용자가 wxt.config.ts 에 별도 exclude 를 설정하지 않아도 자동 적용된다.
83
+ config() {
84
+ return {
85
+ optimizeDeps: {
86
+ exclude: OPTIMIZE_DEPS_EXCLUDE
87
+ }
88
+ };
89
+ },
66
90
  configResolved(config) {
67
91
  var _a, _b;
68
92
  isServe = config.command === 'serve';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@locuschain/lib",
3
- "version": "0.1.40",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "author": "bloomtechnology",
6
6
  "license": "MIT",