tamagui-loader 1.0.1-beta.70 → 1.0.1-beta.73

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/cjs/css.js CHANGED
@@ -16,7 +16,6 @@ var __spreadValues = (a, b) => {
16
16
  }
17
17
  return a;
18
18
  };
19
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
20
19
  var __export = (target, all) => {
21
20
  for (var name in all)
22
21
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -54,12 +53,11 @@ function loader() {
54
53
  } else if (options.cssData) {
55
54
  out = Buffer.from(options.cssData, "base64").toString("utf-8");
56
55
  }
57
- if (options.cssData || options.cssPath) {
56
+ if (out) {
58
57
  return this.callback(null, out || "");
59
58
  }
60
59
  this.callback({ message: `No CSS found`, name: "missing_css" });
61
60
  }
62
- __name(loader, "loader");
63
61
  // Annotate the CommonJS export names for ESM import in node:
64
62
  0 && (module.exports = {
65
63
  extractedInfoByFile,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/css.ts"],
4
- "sourcesContent": ["import { ExtractedResponse, TamaguiOptions } from '@tamagui/static'\nimport { LoaderContext } from 'webpack'\n\nexport const extractedInfoByFile = new Map<string, ExtractedResponse>()\nexport const stylePathToFilePath = new Map<string, string>()\n\nexport default function loader(this: LoaderContext<any>) {\n this.async()\n const options: TamaguiOptions = { ...this.getOptions() }\n const sourcePath = `${this.resourcePath}`\n let out = ''\n if (options.cssPath) {\n // get in memory info\n const pathKey = stylePathToFilePath.get(sourcePath) ?? sourcePath\n const info = extractedInfoByFile.get(pathKey)\n // clear memory\n stylePathToFilePath.delete(sourcePath)\n extractedInfoByFile.delete(pathKey)\n const out = info?.styles\n return this.callback(null, out || '')\n } else if (options.cssData) {\n // get output CSS\n out = Buffer.from(options.cssData, 'base64').toString('utf-8')\n }\n if (options.cssData || options.cssPath) {\n // use original JS sourcemap\n return this.callback(null, out || '')\n }\n this.callback({ message: `No CSS found`, name: 'missing_css' })\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,sBAAsB,oBAAI,IAA+B;AAC/D,MAAM,sBAAsB,oBAAI,IAAoB;AAE5C,kBAA0C;AACvD,OAAK,MAAM;AACX,QAAM,UAA0B,mBAAK,KAAK,WAAW;AACrD,QAAM,aAAa,GAAG,KAAK;AAC3B,MAAI,MAAM;AACV,MAAI,QAAQ,SAAS;AAEnB,UAAM,UAAU,oBAAoB,IAAI,UAAU,KAAK;AACvD,UAAM,OAAO,oBAAoB,IAAI,OAAO;AAE5C,wBAAoB,OAAO,UAAU;AACrC,wBAAoB,OAAO,OAAO;AAClC,UAAM,OAAM,6BAAM;AAClB,WAAO,KAAK,SAAS,MAAM,QAAO,EAAE;AAAA,EACtC,WAAW,QAAQ,SAAS;AAE1B,UAAM,OAAO,KAAK,QAAQ,SAAS,QAAQ,EAAE,SAAS,OAAO;AAAA,EAC/D;AACA,MAAI,QAAQ,WAAW,QAAQ,SAAS;AAEtC,WAAO,KAAK,SAAS,MAAM,OAAO,EAAE;AAAA,EACtC;AACA,OAAK,SAAS,EAAE,SAAS,gBAAgB,MAAM,cAAc,CAAC;AAChE;AAvBwB;",
4
+ "sourcesContent": ["import { ExtractedResponse, TamaguiOptions } from '@tamagui/static'\nimport { LoaderContext } from 'webpack'\n\nexport const extractedInfoByFile = new Map<string, ExtractedResponse>()\nexport const stylePathToFilePath = new Map<string, string>()\n\nexport default function loader(this: LoaderContext<any>) {\n this.async()\n const options: TamaguiOptions = { ...this.getOptions() }\n const sourcePath = `${this.resourcePath}`\n let out = ''\n if (options.cssPath) {\n // get in memory info\n const pathKey = stylePathToFilePath.get(sourcePath) ?? sourcePath\n const info = extractedInfoByFile.get(pathKey)\n // clear memory\n stylePathToFilePath.delete(sourcePath)\n extractedInfoByFile.delete(pathKey)\n const out = info?.styles\n return this.callback(null, out || '')\n } else if (options.cssData) {\n // get output CSS\n out = Buffer.from(options.cssData, 'base64').toString('utf-8')\n }\n if (out) {\n // use original JS sourcemap\n return this.callback(null, out || '')\n }\n this.callback({ message: `No CSS found`, name: 'missing_css' })\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,sBAAsB,oBAAI,IAA+B;AAC/D,MAAM,sBAAsB,oBAAI,IAAoB;AAE5C,kBAA0C;AACvD,OAAK,MAAM;AACX,QAAM,UAA0B,mBAAK,KAAK,WAAW;AACrD,QAAM,aAAa,GAAG,KAAK;AAC3B,MAAI,MAAM;AACV,MAAI,QAAQ,SAAS;AAEnB,UAAM,UAAU,oBAAoB,IAAI,UAAU,KAAK;AACvD,UAAM,OAAO,oBAAoB,IAAI,OAAO;AAE5C,wBAAoB,OAAO,UAAU;AACrC,wBAAoB,OAAO,OAAO;AAClC,UAAM,OAAM,6BAAM;AAClB,WAAO,KAAK,SAAS,MAAM,QAAO,EAAE;AAAA,EACtC,WAAW,QAAQ,SAAS;AAE1B,UAAM,OAAO,KAAK,QAAQ,SAAS,QAAQ,EAAE,SAAS,OAAO;AAAA,EAC/D;AACA,MAAI,KAAK;AAEP,WAAO,KAAK,SAAS,MAAM,OAAO,EAAE;AAAA,EACtC;AACA,OAAK,SAAS,EAAE,SAAS,gBAAgB,MAAM,cAAc,CAAC;AAChE;",
6
6
  "names": []
7
7
  }
package/dist/cjs/index.js CHANGED
@@ -2,7 +2,6 @@ var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
5
  var __export = (target, all) => {
7
6
  for (var name in all)
8
7
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -25,12 +24,12 @@ module.exports = __toCommonJS(src_exports);
25
24
  process.env.TAMAGUI_TARGET = process.env.TAMAGUI_TARGET || "web";
26
25
  process.env.TAMAGUI_COMPILE_PROCESS = "1";
27
26
  var src_default = require("./loader").loader;
28
- const shouldExclude = /* @__PURE__ */ __name((path, projectRoot) => {
27
+ const shouldExclude = (path, projectRoot) => {
29
28
  if (path.includes("react-native-reanimated") || path.includes("react-native-gesture-handler") || path.includes("@gorhom/portal") || path.includes(projectRoot) || path.includes("/dist/jsx/")) {
30
29
  return false;
31
30
  }
32
31
  return true;
33
- }, "shouldExclude");
32
+ };
34
33
  // Annotate the CommonJS export names for ESM import in node:
35
34
  0 && (module.exports = {
36
35
  shouldExclude
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
4
  "sourcesContent": ["process.env.TAMAGUI_TARGET = process.env.TAMAGUI_TARGET || 'web'\nprocess.env.TAMAGUI_COMPILE_PROCESS = '1'\n\nexport default require('./loader').loader\n\n// helper for webpack exclude specific to tamagui\n\nexport const shouldExclude = (path: string, projectRoot: string) => {\n if (\n path.includes('react-native-reanimated') ||\n path.includes('react-native-gesture-handler') ||\n path.includes('@gorhom/portal') ||\n path.includes(projectRoot) ||\n path.includes('/dist/jsx/')\n ) {\n return false\n }\n return true\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAAQ,IAAI,iBAAiB,QAAQ,IAAI,kBAAkB;AAC3D,QAAQ,IAAI,0BAA0B;AAEtC,IAAO,cAAQ,QAAQ,UAAU,EAAE;AAI5B,MAAM,gBAAgB,wBAAC,MAAc,gBAAwB;AAClE,MACE,KAAK,SAAS,yBAAyB,KACvC,KAAK,SAAS,8BAA8B,KAC5C,KAAK,SAAS,gBAAgB,KAC9B,KAAK,SAAS,WAAW,KACzB,KAAK,SAAS,YAAY,GAC1B;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT,GAX6B;",
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAAQ,IAAI,iBAAiB,QAAQ,IAAI,kBAAkB;AAC3D,QAAQ,IAAI,0BAA0B;AAEtC,IAAO,cAAQ,QAAQ,UAAU,EAAE;AAI5B,MAAM,gBAAgB,CAAC,MAAc,gBAAwB;AAClE,MACE,KAAK,SAAS,yBAAyB,KACvC,KAAK,SAAS,8BAA8B,KAC5C,KAAK,SAAS,gBAAgB,KAC9B,KAAK,SAAS,WAAW,KACzB,KAAK,SAAS,YAAY,GAC1B;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -18,7 +18,6 @@ var __spreadValues = (a, b) => {
18
18
  }
19
19
  return a;
20
20
  };
21
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
22
21
  var __export = (target, all) => {
23
22
  for (var name in all)
24
23
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -46,9 +45,10 @@ const extractor = (0, import_static.createExtractor)();
46
45
  let index = 0;
47
46
  let hasPatched = false;
48
47
  process.env.TAMAGUI_TARGET = "web";
49
- function loader(source) {
50
- this.cacheable();
48
+ const loader = function loader2(sourceIn) {
49
+ this.cacheable(true);
51
50
  this.async();
51
+ const source = sourceIn.toString();
52
52
  if (!process.env.TAMAGUI_DISABLE_RNW_PATCH && !hasPatched) {
53
53
  (0, import_static.patchReactNativeWeb)();
54
54
  hasPatched = true;
@@ -67,19 +67,23 @@ function loader(source) {
67
67
  }
68
68
  const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`;
69
69
  const extracted = (0, import_static.extractToClassNames)({
70
- loader: this,
71
70
  extractor,
72
- cssLoaderPath: CSS_LOADER_PATH,
73
71
  source,
74
- threaded,
75
72
  sourcePath,
76
- cssPath,
77
73
  options,
78
74
  shouldPrintDebug
79
75
  });
80
76
  if (!extracted) {
81
77
  return this.callback(null, source);
82
78
  }
79
+ if (extracted.styles) {
80
+ const cssQuery = threaded ? `cssData=${Buffer.from(extracted.styles).toString("base64")}` : `cssPath=${cssPath}`;
81
+ const remReq = this.remainingRequest;
82
+ const importPath = `${cssPath}!=!${CSS_LOADER_PATH}?${cssQuery}!${remReq}`;
83
+ extracted.js = `${extracted.js}
84
+
85
+ require(${JSON.stringify(importPath)})`;
86
+ }
83
87
  import_css.extractedInfoByFile.set(sourcePath, extracted);
84
88
  if (!threaded) {
85
89
  if (extracted.stylesPath) {
@@ -91,8 +95,7 @@ function loader(source) {
91
95
  console.error("ERROR", err);
92
96
  return this.callback(null, source);
93
97
  }
94
- }
95
- __name(loader, "loader");
98
+ };
96
99
  // Annotate the CommonJS export names for ESM import in node:
97
100
  0 && (module.exports = {
98
101
  loader
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/loader.ts"],
4
- "sourcesContent": ["import {\n TamaguiOptions,\n createExtractor,\n extractToClassNames,\n patchReactNativeWeb,\n} from '@tamagui/static'\nimport { LoaderContext } from 'webpack'\n\nimport { extractedInfoByFile, stylePathToFilePath } from './css'\n\n// pass loader as path\nconst CSS_LOADER_PATH = require.resolve('./css')\n\nError.stackTraceLimit = Infinity\nconst extractor = createExtractor()\n\nlet index = 0\nlet hasPatched = false\n\nprocess.env.TAMAGUI_TARGET = 'web'\n\nexport function loader(this: LoaderContext<any>, source: string) {\n this.cacheable()\n this.async()\n\n if (!process.env.TAMAGUI_DISABLE_RNW_PATCH && !hasPatched) {\n patchReactNativeWeb()\n hasPatched = true\n }\n\n try {\n const threaded = this.emitFile === undefined\n const options: TamaguiOptions = { ...this.getOptions() }\n const sourcePath = `${this.resourcePath}`\n const startsWithComment = source[0] === '/' && source[1] === '/'\n\n let shouldPrintDebug: boolean | 'verbose' =\n (!!process.env.DEBUG &&\n (process.env.DEBUG_FILE ? sourcePath.includes(process.env.DEBUG_FILE) : true)) ||\n // supports esbuild style //! comments\n (startsWithComment && (source.startsWith('// debug') || source.startsWith('//! debug')))\n\n if (shouldPrintDebug && source.startsWith('// debug-verbose')) {\n shouldPrintDebug = 'verbose'\n }\n\n // check if should ignore\n if (\n startsWithComment &&\n (source.startsWith('// tamagui-ignore') || source.startsWith('//! tamagui-ignore'))\n ) {\n return this.callback(null, source)\n }\n\n const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`\n\n const extracted = extractToClassNames({\n loader: this,\n extractor,\n cssLoaderPath: CSS_LOADER_PATH,\n source,\n threaded,\n sourcePath,\n cssPath,\n options,\n shouldPrintDebug,\n })\n\n if (!extracted) {\n return this.callback(null, source)\n }\n\n extractedInfoByFile.set(sourcePath, extracted)\n\n if (!threaded) {\n if (extracted.stylesPath) {\n stylePathToFilePath.set(extracted.stylesPath, sourcePath)\n }\n }\n\n this.callback(null, extracted.js, extracted.map)\n } catch (err) {\n console.error('ERROR', err)\n return this.callback(null, source)\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAKO;AAGP,iBAAyD;AAGzD,MAAM,kBAAkC;AAExC,MAAM,kBAAkB;AACxB,MAAM,YAAY,mCAAgB;AAElC,IAAI,QAAQ;AACZ,IAAI,aAAa;AAEjB,QAAQ,IAAI,iBAAiB;AAEtB,gBAA0C,QAAgB;AAC/D,OAAK,UAAU;AACf,OAAK,MAAM;AAEX,MAAI,CAAC,QAAQ,IAAI,6BAA6B,CAAC,YAAY;AACzD,2CAAoB;AACpB,iBAAa;AAAA,EACf;AAEA,MAAI;AACF,UAAM,WAAW,KAAK,aAAa;AACnC,UAAM,UAA0B,mBAAK,KAAK,WAAW;AACrD,UAAM,aAAa,GAAG,KAAK;AAC3B,UAAM,oBAAoB,OAAO,OAAO,OAAO,OAAO,OAAO;AAE7D,QAAI,mBACD,CAAC,CAAC,QAAQ,IAAI,SACZ,SAAQ,IAAI,aAAa,WAAW,SAAS,QAAQ,IAAI,UAAU,IAAI,SAEzE,qBAAsB,QAAO,WAAW,UAAU,KAAK,OAAO,WAAW,WAAW;AAEvF,QAAI,oBAAoB,OAAO,WAAW,kBAAkB,GAAG;AAC7D,yBAAmB;AAAA,IACrB;AAGA,QACE,qBACC,QAAO,WAAW,mBAAmB,KAAK,OAAO,WAAW,oBAAoB,IACjF;AACA,aAAO,KAAK,SAAS,MAAM,MAAM;AAAA,IACnC;AAEA,UAAM,UAAU,WAAW,GAAG,0BAA0B,GAAG,cAAc;AAEzE,UAAM,YAAY,uCAAoB;AAAA,MACpC,QAAQ;AAAA,MACR;AAAA,MACA,eAAe;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,QAAI,CAAC,WAAW;AACd,aAAO,KAAK,SAAS,MAAM,MAAM;AAAA,IACnC;AAEA,mCAAoB,IAAI,YAAY,SAAS;AAE7C,QAAI,CAAC,UAAU;AACb,UAAI,UAAU,YAAY;AACxB,uCAAoB,IAAI,UAAU,YAAY,UAAU;AAAA,MAC1D;AAAA,IACF;AAEA,SAAK,SAAS,MAAM,UAAU,IAAI,UAAU,GAAG;AAAA,EACjD,SAAS,KAAP;AACA,YAAQ,MAAM,SAAS,GAAG;AAC1B,WAAO,KAAK,SAAS,MAAM,MAAM;AAAA,EACnC;AACF;AAhEgB;",
4
+ "sourcesContent": ["import {\n TamaguiOptions,\n createExtractor,\n extractToClassNames,\n patchReactNativeWeb,\n} from '@tamagui/static'\nimport type { LoaderContext, RawLoaderDefinitionFunction } from 'webpack'\n\nimport { extractedInfoByFile, stylePathToFilePath } from './css'\n\n// pass loader as path\nconst CSS_LOADER_PATH = require.resolve('./css')\n\nError.stackTraceLimit = Infinity\nconst extractor = createExtractor()\n\nlet index = 0\nlet hasPatched = false\n\nprocess.env.TAMAGUI_TARGET = 'web'\n\nexport const loader: RawLoaderDefinitionFunction<TamaguiOptions> = function loader(this, sourceIn) {\n this.cacheable(true)\n this.async()\n const source = sourceIn.toString()\n\n if (!process.env.TAMAGUI_DISABLE_RNW_PATCH && !hasPatched) {\n patchReactNativeWeb()\n hasPatched = true\n }\n\n try {\n const threaded = this.emitFile === undefined\n const options: TamaguiOptions = { ...this.getOptions() }\n const sourcePath = `${this.resourcePath}`\n const startsWithComment = source[0] === '/' && source[1] === '/'\n\n let shouldPrintDebug: boolean | 'verbose' =\n (!!process.env.DEBUG &&\n (process.env.DEBUG_FILE ? sourcePath.includes(process.env.DEBUG_FILE) : true)) ||\n // supports esbuild style //! comments\n (startsWithComment && (source.startsWith('// debug') || source.startsWith('//! debug')))\n\n if (shouldPrintDebug && source.startsWith('// debug-verbose')) {\n shouldPrintDebug = 'verbose'\n }\n\n // check if should ignore\n if (\n startsWithComment &&\n (source.startsWith('// tamagui-ignore') || source.startsWith('//! tamagui-ignore'))\n ) {\n return this.callback(null, source)\n }\n\n const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`\n\n // cssLoaderPath: CSS_LOADER_PATH,\n // threaded,\n // cssPath,\n\n const extracted = extractToClassNames({\n extractor,\n source,\n sourcePath,\n options,\n shouldPrintDebug,\n })\n\n if (!extracted) {\n return this.callback(null, source)\n }\n\n // add import to css\n if (extracted.styles) {\n const cssQuery = threaded\n ? `cssData=${Buffer.from(extracted.styles).toString('base64')}`\n : `cssPath=${cssPath}`\n const remReq = this.remainingRequest\n const importPath = `${cssPath}!=!${CSS_LOADER_PATH}?${cssQuery}!${remReq}`\n extracted.js = `${extracted.js}\\n\\nrequire(${JSON.stringify(importPath)})`\n }\n\n extractedInfoByFile.set(sourcePath, extracted)\n\n if (!threaded) {\n if (extracted.stylesPath) {\n stylePathToFilePath.set(extracted.stylesPath, sourcePath)\n }\n }\n\n this.callback(null, extracted.js, extracted.map)\n } catch (err) {\n console.error('ERROR', err)\n return this.callback(null, source)\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAKO;AAGP,iBAAyD;AAGzD,MAAM,kBAAkC;AAExC,MAAM,kBAAkB;AACxB,MAAM,YAAY,mCAAgB;AAElC,IAAI,QAAQ;AACZ,IAAI,aAAa;AAEjB,QAAQ,IAAI,iBAAiB;AAEtB,MAAM,SAAsD,iBAAsB,UAAU;AACjG,OAAK,UAAU,IAAI;AACnB,OAAK,MAAM;AACX,QAAM,SAAS,SAAS,SAAS;AAEjC,MAAI,CAAC,QAAQ,IAAI,6BAA6B,CAAC,YAAY;AACzD,2CAAoB;AACpB,iBAAa;AAAA,EACf;AAEA,MAAI;AACF,UAAM,WAAW,KAAK,aAAa;AACnC,UAAM,UAA0B,mBAAK,KAAK,WAAW;AACrD,UAAM,aAAa,GAAG,KAAK;AAC3B,UAAM,oBAAoB,OAAO,OAAO,OAAO,OAAO,OAAO;AAE7D,QAAI,mBACD,CAAC,CAAC,QAAQ,IAAI,SACZ,SAAQ,IAAI,aAAa,WAAW,SAAS,QAAQ,IAAI,UAAU,IAAI,SAEzE,qBAAsB,QAAO,WAAW,UAAU,KAAK,OAAO,WAAW,WAAW;AAEvF,QAAI,oBAAoB,OAAO,WAAW,kBAAkB,GAAG;AAC7D,yBAAmB;AAAA,IACrB;AAGA,QACE,qBACC,QAAO,WAAW,mBAAmB,KAAK,OAAO,WAAW,oBAAoB,IACjF;AACA,aAAO,KAAK,SAAS,MAAM,MAAM;AAAA,IACnC;AAEA,UAAM,UAAU,WAAW,GAAG,0BAA0B,GAAG,cAAc;AAMzE,UAAM,YAAY,uCAAoB;AAAA,MACpC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,QAAI,CAAC,WAAW;AACd,aAAO,KAAK,SAAS,MAAM,MAAM;AAAA,IACnC;AAGA,QAAI,UAAU,QAAQ;AACpB,YAAM,WAAW,WACb,WAAW,OAAO,KAAK,UAAU,MAAM,EAAE,SAAS,QAAQ,MAC1D,WAAW;AACf,YAAM,SAAS,KAAK;AACpB,YAAM,aAAa,GAAG,aAAa,mBAAmB,YAAY;AAClE,gBAAU,KAAK,GAAG,UAAU;AAAA;AAAA,UAAiB,KAAK,UAAU,UAAU;AAAA,IACxE;AAEA,mCAAoB,IAAI,YAAY,SAAS;AAE7C,QAAI,CAAC,UAAU;AACb,UAAI,UAAU,YAAY;AACxB,uCAAoB,IAAI,UAAU,YAAY,UAAU;AAAA,MAC1D;AAAA,IACF;AAEA,SAAK,SAAS,MAAM,UAAU,IAAI,UAAU,GAAG;AAAA,EACjD,SAAS,KAAP;AACA,YAAQ,MAAM,SAAS,GAAG;AAC1B,WAAO,KAAK,SAAS,MAAM,MAAM;AAAA,EACnC;AACF;",
6
6
  "names": []
7
7
  }
package/dist/esm/css.js CHANGED
@@ -1,5 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
1
  const extractedInfoByFile = /* @__PURE__ */ new Map();
4
2
  const stylePathToFilePath = /* @__PURE__ */ new Map();
5
3
  function loader() {
@@ -18,12 +16,11 @@ function loader() {
18
16
  } else if (options.cssData) {
19
17
  out = Buffer.from(options.cssData, "base64").toString("utf-8");
20
18
  }
21
- if (options.cssData || options.cssPath) {
19
+ if (out) {
22
20
  return this.callback(null, out || "");
23
21
  }
24
22
  this.callback({ message: `No CSS found`, name: "missing_css" });
25
23
  }
26
- __name(loader, "loader");
27
24
  export {
28
25
  loader as default,
29
26
  extractedInfoByFile,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/css.ts"],
4
- "sourcesContent": ["import { ExtractedResponse, TamaguiOptions } from '@tamagui/static'\nimport { LoaderContext } from 'webpack'\n\nexport const extractedInfoByFile = new Map<string, ExtractedResponse>()\nexport const stylePathToFilePath = new Map<string, string>()\n\nexport default function loader(this: LoaderContext<any>) {\n this.async()\n const options: TamaguiOptions = { ...this.getOptions() }\n const sourcePath = `${this.resourcePath}`\n let out = ''\n if (options.cssPath) {\n // get in memory info\n const pathKey = stylePathToFilePath.get(sourcePath) ?? sourcePath\n const info = extractedInfoByFile.get(pathKey)\n // clear memory\n stylePathToFilePath.delete(sourcePath)\n extractedInfoByFile.delete(pathKey)\n const out = info?.styles\n return this.callback(null, out || '')\n } else if (options.cssData) {\n // get output CSS\n out = Buffer.from(options.cssData, 'base64').toString('utf-8')\n }\n if (options.cssData || options.cssPath) {\n // use original JS sourcemap\n return this.callback(null, out || '')\n }\n this.callback({ message: `No CSS found`, name: 'missing_css' })\n}\n"],
5
- "mappings": ";;AAGO,MAAM,sBAAsB,oBAAI,IAA+B;AAC/D,MAAM,sBAAsB,oBAAI,IAAoB;AAE5C,kBAA0C;AANzD;AAOE,OAAK,MAAM;AACX,QAAM,UAA0B,EAAE,GAAG,KAAK,WAAW,EAAE;AACvD,QAAM,aAAa,GAAG,KAAK;AAC3B,MAAI,MAAM;AACV,MAAI,QAAQ,SAAS;AAEnB,UAAM,UAAU,0BAAoB,IAAI,UAAU,MAAlC,YAAuC;AACvD,UAAM,OAAO,oBAAoB,IAAI,OAAO;AAE5C,wBAAoB,OAAO,UAAU;AACrC,wBAAoB,OAAO,OAAO;AAClC,UAAM,OAAM,6BAAM;AAClB,WAAO,KAAK,SAAS,MAAM,QAAO,EAAE;AAAA,EACtC,WAAW,QAAQ,SAAS;AAE1B,UAAM,OAAO,KAAK,QAAQ,SAAS,QAAQ,EAAE,SAAS,OAAO;AAAA,EAC/D;AACA,MAAI,QAAQ,WAAW,QAAQ,SAAS;AAEtC,WAAO,KAAK,SAAS,MAAM,OAAO,EAAE;AAAA,EACtC;AACA,OAAK,SAAS,EAAE,SAAS,gBAAgB,MAAM,cAAc,CAAC;AAChE;AAvBwB;",
4
+ "sourcesContent": ["import { ExtractedResponse, TamaguiOptions } from '@tamagui/static'\nimport { LoaderContext } from 'webpack'\n\nexport const extractedInfoByFile = new Map<string, ExtractedResponse>()\nexport const stylePathToFilePath = new Map<string, string>()\n\nexport default function loader(this: LoaderContext<any>) {\n this.async()\n const options: TamaguiOptions = { ...this.getOptions() }\n const sourcePath = `${this.resourcePath}`\n let out = ''\n if (options.cssPath) {\n // get in memory info\n const pathKey = stylePathToFilePath.get(sourcePath) ?? sourcePath\n const info = extractedInfoByFile.get(pathKey)\n // clear memory\n stylePathToFilePath.delete(sourcePath)\n extractedInfoByFile.delete(pathKey)\n const out = info?.styles\n return this.callback(null, out || '')\n } else if (options.cssData) {\n // get output CSS\n out = Buffer.from(options.cssData, 'base64').toString('utf-8')\n }\n if (out) {\n // use original JS sourcemap\n return this.callback(null, out || '')\n }\n this.callback({ message: `No CSS found`, name: 'missing_css' })\n}\n"],
5
+ "mappings": "AAGO,MAAM,sBAAsB,oBAAI,IAA+B;AAC/D,MAAM,sBAAsB,oBAAI,IAAoB;AAE5C,kBAA0C;AANzD;AAOE,OAAK,MAAM;AACX,QAAM,UAA0B,EAAE,GAAG,KAAK,WAAW,EAAE;AACvD,QAAM,aAAa,GAAG,KAAK;AAC3B,MAAI,MAAM;AACV,MAAI,QAAQ,SAAS;AAEnB,UAAM,UAAU,0BAAoB,IAAI,UAAU,MAAlC,YAAuC;AACvD,UAAM,OAAO,oBAAoB,IAAI,OAAO;AAE5C,wBAAoB,OAAO,UAAU;AACrC,wBAAoB,OAAO,OAAO;AAClC,UAAM,OAAM,6BAAM;AAClB,WAAO,KAAK,SAAS,MAAM,QAAO,EAAE;AAAA,EACtC,WAAW,QAAQ,SAAS;AAE1B,UAAM,OAAO,KAAK,QAAQ,SAAS,QAAQ,EAAE,SAAS,OAAO;AAAA,EAC/D;AACA,MAAI,KAAK;AAEP,WAAO,KAAK,SAAS,MAAM,OAAO,EAAE;AAAA,EACtC;AACA,OAAK,SAAS,EAAE,SAAS,gBAAgB,MAAM,cAAc,CAAC;AAChE;",
6
6
  "names": []
7
7
  }
package/dist/esm/index.js CHANGED
@@ -1,14 +1,12 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
1
  process.env.TAMAGUI_TARGET = process.env.TAMAGUI_TARGET || "web";
4
2
  process.env.TAMAGUI_COMPILE_PROCESS = "1";
5
3
  var src_default = require("./loader").loader;
6
- const shouldExclude = /* @__PURE__ */ __name((path, projectRoot) => {
4
+ const shouldExclude = (path, projectRoot) => {
7
5
  if (path.includes("react-native-reanimated") || path.includes("react-native-gesture-handler") || path.includes("@gorhom/portal") || path.includes(projectRoot) || path.includes("/dist/jsx/")) {
8
6
  return false;
9
7
  }
10
8
  return true;
11
- }, "shouldExclude");
9
+ };
12
10
  export {
13
11
  src_default as default,
14
12
  shouldExclude
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
4
  "sourcesContent": ["process.env.TAMAGUI_TARGET = process.env.TAMAGUI_TARGET || 'web'\nprocess.env.TAMAGUI_COMPILE_PROCESS = '1'\n\nexport default require('./loader').loader\n\n// helper for webpack exclude specific to tamagui\n\nexport const shouldExclude = (path: string, projectRoot: string) => {\n if (\n path.includes('react-native-reanimated') ||\n path.includes('react-native-gesture-handler') ||\n path.includes('@gorhom/portal') ||\n path.includes(projectRoot) ||\n path.includes('/dist/jsx/')\n ) {\n return false\n }\n return true\n}\n"],
5
- "mappings": ";;AAAA,QAAQ,IAAI,iBAAiB,QAAQ,IAAI,kBAAkB;AAC3D,QAAQ,IAAI,0BAA0B;AAEtC,IAAO,cAAQ,QAAQ,UAAU,EAAE;AAI5B,MAAM,gBAAgB,wBAAC,MAAc,gBAAwB;AAClE,MACE,KAAK,SAAS,yBAAyB,KACvC,KAAK,SAAS,8BAA8B,KAC5C,KAAK,SAAS,gBAAgB,KAC9B,KAAK,SAAS,WAAW,KACzB,KAAK,SAAS,YAAY,GAC1B;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT,GAX6B;",
5
+ "mappings": "AAAA,QAAQ,IAAI,iBAAiB,QAAQ,IAAI,kBAAkB;AAC3D,QAAQ,IAAI,0BAA0B;AAEtC,IAAO,cAAQ,QAAQ,UAAU,EAAE;AAI5B,MAAM,gBAAgB,CAAC,MAAc,gBAAwB;AAClE,MACE,KAAK,SAAS,yBAAyB,KACvC,KAAK,SAAS,8BAA8B,KAC5C,KAAK,SAAS,gBAAgB,KAC9B,KAAK,SAAS,WAAW,KACzB,KAAK,SAAS,YAAY,GAC1B;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
1
  import {
4
2
  createExtractor,
5
3
  extractToClassNames,
@@ -12,9 +10,10 @@ const extractor = createExtractor();
12
10
  let index = 0;
13
11
  let hasPatched = false;
14
12
  process.env.TAMAGUI_TARGET = "web";
15
- function loader(source) {
16
- this.cacheable();
13
+ const loader = function loader2(sourceIn) {
14
+ this.cacheable(true);
17
15
  this.async();
16
+ const source = sourceIn.toString();
18
17
  if (!process.env.TAMAGUI_DISABLE_RNW_PATCH && !hasPatched) {
19
18
  patchReactNativeWeb();
20
19
  hasPatched = true;
@@ -33,19 +32,23 @@ function loader(source) {
33
32
  }
34
33
  const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`;
35
34
  const extracted = extractToClassNames({
36
- loader: this,
37
35
  extractor,
38
- cssLoaderPath: CSS_LOADER_PATH,
39
36
  source,
40
- threaded,
41
37
  sourcePath,
42
- cssPath,
43
38
  options,
44
39
  shouldPrintDebug
45
40
  });
46
41
  if (!extracted) {
47
42
  return this.callback(null, source);
48
43
  }
44
+ if (extracted.styles) {
45
+ const cssQuery = threaded ? `cssData=${Buffer.from(extracted.styles).toString("base64")}` : `cssPath=${cssPath}`;
46
+ const remReq = this.remainingRequest;
47
+ const importPath = `${cssPath}!=!${CSS_LOADER_PATH}?${cssQuery}!${remReq}`;
48
+ extracted.js = `${extracted.js}
49
+
50
+ require(${JSON.stringify(importPath)})`;
51
+ }
49
52
  extractedInfoByFile.set(sourcePath, extracted);
50
53
  if (!threaded) {
51
54
  if (extracted.stylesPath) {
@@ -57,8 +60,7 @@ function loader(source) {
57
60
  console.error("ERROR", err);
58
61
  return this.callback(null, source);
59
62
  }
60
- }
61
- __name(loader, "loader");
63
+ };
62
64
  export {
63
65
  loader
64
66
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/loader.ts"],
4
- "sourcesContent": ["import {\n TamaguiOptions,\n createExtractor,\n extractToClassNames,\n patchReactNativeWeb,\n} from '@tamagui/static'\nimport { LoaderContext } from 'webpack'\n\nimport { extractedInfoByFile, stylePathToFilePath } from './css'\n\n// pass loader as path\nconst CSS_LOADER_PATH = require.resolve('./css')\n\nError.stackTraceLimit = Infinity\nconst extractor = createExtractor()\n\nlet index = 0\nlet hasPatched = false\n\nprocess.env.TAMAGUI_TARGET = 'web'\n\nexport function loader(this: LoaderContext<any>, source: string) {\n this.cacheable()\n this.async()\n\n if (!process.env.TAMAGUI_DISABLE_RNW_PATCH && !hasPatched) {\n patchReactNativeWeb()\n hasPatched = true\n }\n\n try {\n const threaded = this.emitFile === undefined\n const options: TamaguiOptions = { ...this.getOptions() }\n const sourcePath = `${this.resourcePath}`\n const startsWithComment = source[0] === '/' && source[1] === '/'\n\n let shouldPrintDebug: boolean | 'verbose' =\n (!!process.env.DEBUG &&\n (process.env.DEBUG_FILE ? sourcePath.includes(process.env.DEBUG_FILE) : true)) ||\n // supports esbuild style //! comments\n (startsWithComment && (source.startsWith('// debug') || source.startsWith('//! debug')))\n\n if (shouldPrintDebug && source.startsWith('// debug-verbose')) {\n shouldPrintDebug = 'verbose'\n }\n\n // check if should ignore\n if (\n startsWithComment &&\n (source.startsWith('// tamagui-ignore') || source.startsWith('//! tamagui-ignore'))\n ) {\n return this.callback(null, source)\n }\n\n const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`\n\n const extracted = extractToClassNames({\n loader: this,\n extractor,\n cssLoaderPath: CSS_LOADER_PATH,\n source,\n threaded,\n sourcePath,\n cssPath,\n options,\n shouldPrintDebug,\n })\n\n if (!extracted) {\n return this.callback(null, source)\n }\n\n extractedInfoByFile.set(sourcePath, extracted)\n\n if (!threaded) {\n if (extracted.stylesPath) {\n stylePathToFilePath.set(extracted.stylesPath, sourcePath)\n }\n }\n\n this.callback(null, extracted.js, extracted.map)\n } catch (err) {\n console.error('ERROR', err)\n return this.callback(null, source)\n }\n}\n"],
5
- "mappings": ";;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA;AAGA,MAAM,kBAAkC;AAExC,MAAM,kBAAkB;AACxB,MAAM,YAAY,gBAAgB;AAElC,IAAI,QAAQ;AACZ,IAAI,aAAa;AAEjB,QAAQ,IAAI,iBAAiB;AAEtB,gBAA0C,QAAgB;AAC/D,OAAK,UAAU;AACf,OAAK,MAAM;AAEX,MAAI,CAAC,QAAQ,IAAI,6BAA6B,CAAC,YAAY;AACzD,wBAAoB;AACpB,iBAAa;AAAA,EACf;AAEA,MAAI;AACF,UAAM,WAAW,KAAK,aAAa;AACnC,UAAM,UAA0B,EAAE,GAAG,KAAK,WAAW,EAAE;AACvD,UAAM,aAAa,GAAG,KAAK;AAC3B,UAAM,oBAAoB,OAAO,OAAO,OAAO,OAAO,OAAO;AAE7D,QAAI,mBACD,CAAC,CAAC,QAAQ,IAAI,SACZ,SAAQ,IAAI,aAAa,WAAW,SAAS,QAAQ,IAAI,UAAU,IAAI,SAEzE,qBAAsB,QAAO,WAAW,UAAU,KAAK,OAAO,WAAW,WAAW;AAEvF,QAAI,oBAAoB,OAAO,WAAW,kBAAkB,GAAG;AAC7D,yBAAmB;AAAA,IACrB;AAGA,QACE,qBACC,QAAO,WAAW,mBAAmB,KAAK,OAAO,WAAW,oBAAoB,IACjF;AACA,aAAO,KAAK,SAAS,MAAM,MAAM;AAAA,IACnC;AAEA,UAAM,UAAU,WAAW,GAAG,0BAA0B,GAAG,cAAc;AAEzE,UAAM,YAAY,oBAAoB;AAAA,MACpC,QAAQ;AAAA,MACR;AAAA,MACA,eAAe;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,QAAI,CAAC,WAAW;AACd,aAAO,KAAK,SAAS,MAAM,MAAM;AAAA,IACnC;AAEA,wBAAoB,IAAI,YAAY,SAAS;AAE7C,QAAI,CAAC,UAAU;AACb,UAAI,UAAU,YAAY;AACxB,4BAAoB,IAAI,UAAU,YAAY,UAAU;AAAA,MAC1D;AAAA,IACF;AAEA,SAAK,SAAS,MAAM,UAAU,IAAI,UAAU,GAAG;AAAA,EACjD,SAAS,KAAP;AACA,YAAQ,MAAM,SAAS,GAAG;AAC1B,WAAO,KAAK,SAAS,MAAM,MAAM;AAAA,EACnC;AACF;AAhEgB;",
4
+ "sourcesContent": ["import {\n TamaguiOptions,\n createExtractor,\n extractToClassNames,\n patchReactNativeWeb,\n} from '@tamagui/static'\nimport type { LoaderContext, RawLoaderDefinitionFunction } from 'webpack'\n\nimport { extractedInfoByFile, stylePathToFilePath } from './css'\n\n// pass loader as path\nconst CSS_LOADER_PATH = require.resolve('./css')\n\nError.stackTraceLimit = Infinity\nconst extractor = createExtractor()\n\nlet index = 0\nlet hasPatched = false\n\nprocess.env.TAMAGUI_TARGET = 'web'\n\nexport const loader: RawLoaderDefinitionFunction<TamaguiOptions> = function loader(this, sourceIn) {\n this.cacheable(true)\n this.async()\n const source = sourceIn.toString()\n\n if (!process.env.TAMAGUI_DISABLE_RNW_PATCH && !hasPatched) {\n patchReactNativeWeb()\n hasPatched = true\n }\n\n try {\n const threaded = this.emitFile === undefined\n const options: TamaguiOptions = { ...this.getOptions() }\n const sourcePath = `${this.resourcePath}`\n const startsWithComment = source[0] === '/' && source[1] === '/'\n\n let shouldPrintDebug: boolean | 'verbose' =\n (!!process.env.DEBUG &&\n (process.env.DEBUG_FILE ? sourcePath.includes(process.env.DEBUG_FILE) : true)) ||\n // supports esbuild style //! comments\n (startsWithComment && (source.startsWith('// debug') || source.startsWith('//! debug')))\n\n if (shouldPrintDebug && source.startsWith('// debug-verbose')) {\n shouldPrintDebug = 'verbose'\n }\n\n // check if should ignore\n if (\n startsWithComment &&\n (source.startsWith('// tamagui-ignore') || source.startsWith('//! tamagui-ignore'))\n ) {\n return this.callback(null, source)\n }\n\n const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`\n\n // cssLoaderPath: CSS_LOADER_PATH,\n // threaded,\n // cssPath,\n\n const extracted = extractToClassNames({\n extractor,\n source,\n sourcePath,\n options,\n shouldPrintDebug,\n })\n\n if (!extracted) {\n return this.callback(null, source)\n }\n\n // add import to css\n if (extracted.styles) {\n const cssQuery = threaded\n ? `cssData=${Buffer.from(extracted.styles).toString('base64')}`\n : `cssPath=${cssPath}`\n const remReq = this.remainingRequest\n const importPath = `${cssPath}!=!${CSS_LOADER_PATH}?${cssQuery}!${remReq}`\n extracted.js = `${extracted.js}\\n\\nrequire(${JSON.stringify(importPath)})`\n }\n\n extractedInfoByFile.set(sourcePath, extracted)\n\n if (!threaded) {\n if (extracted.stylesPath) {\n stylePathToFilePath.set(extracted.stylesPath, sourcePath)\n }\n }\n\n this.callback(null, extracted.js, extracted.map)\n } catch (err) {\n console.error('ERROR', err)\n return this.callback(null, source)\n }\n}\n"],
5
+ "mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAQA;AAGA,MAAM,kBAAkC;AAExC,MAAM,kBAAkB;AACxB,MAAM,YAAY,gBAAgB;AAElC,IAAI,QAAQ;AACZ,IAAI,aAAa;AAEjB,QAAQ,IAAI,iBAAiB;AAEtB,MAAM,SAAsD,iBAAsB,UAAU;AACjG,OAAK,UAAU,IAAI;AACnB,OAAK,MAAM;AACX,QAAM,SAAS,SAAS,SAAS;AAEjC,MAAI,CAAC,QAAQ,IAAI,6BAA6B,CAAC,YAAY;AACzD,wBAAoB;AACpB,iBAAa;AAAA,EACf;AAEA,MAAI;AACF,UAAM,WAAW,KAAK,aAAa;AACnC,UAAM,UAA0B,EAAE,GAAG,KAAK,WAAW,EAAE;AACvD,UAAM,aAAa,GAAG,KAAK;AAC3B,UAAM,oBAAoB,OAAO,OAAO,OAAO,OAAO,OAAO;AAE7D,QAAI,mBACD,CAAC,CAAC,QAAQ,IAAI,SACZ,SAAQ,IAAI,aAAa,WAAW,SAAS,QAAQ,IAAI,UAAU,IAAI,SAEzE,qBAAsB,QAAO,WAAW,UAAU,KAAK,OAAO,WAAW,WAAW;AAEvF,QAAI,oBAAoB,OAAO,WAAW,kBAAkB,GAAG;AAC7D,yBAAmB;AAAA,IACrB;AAGA,QACE,qBACC,QAAO,WAAW,mBAAmB,KAAK,OAAO,WAAW,oBAAoB,IACjF;AACA,aAAO,KAAK,SAAS,MAAM,MAAM;AAAA,IACnC;AAEA,UAAM,UAAU,WAAW,GAAG,0BAA0B,GAAG,cAAc;AAMzE,UAAM,YAAY,oBAAoB;AAAA,MACpC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,QAAI,CAAC,WAAW;AACd,aAAO,KAAK,SAAS,MAAM,MAAM;AAAA,IACnC;AAGA,QAAI,UAAU,QAAQ;AACpB,YAAM,WAAW,WACb,WAAW,OAAO,KAAK,UAAU,MAAM,EAAE,SAAS,QAAQ,MAC1D,WAAW;AACf,YAAM,SAAS,KAAK;AACpB,YAAM,aAAa,GAAG,aAAa,mBAAmB,YAAY;AAClE,gBAAU,KAAK,GAAG,UAAU;AAAA;AAAA,UAAiB,KAAK,UAAU,UAAU;AAAA,IACxE;AAEA,wBAAoB,IAAI,YAAY,SAAS;AAE7C,QAAI,CAAC,UAAU;AACb,UAAI,UAAU,YAAY;AACxB,4BAAoB,IAAI,UAAU,YAAY,UAAU;AAAA,MAC1D;AAAA,IACF;AAEA,SAAK,SAAS,MAAM,UAAU,IAAI,UAAU,GAAG;AAAA,EACjD,SAAS,KAAP;AACA,YAAQ,MAAM,SAAS,GAAG;AAC1B,WAAO,KAAK,SAAS,MAAM,MAAM;AAAA,EACnC;AACF;",
6
6
  "names": []
7
7
  }
package/dist/jsx/css.js CHANGED
@@ -1,5 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
1
  const extractedInfoByFile = /* @__PURE__ */ new Map();
4
2
  const stylePathToFilePath = /* @__PURE__ */ new Map();
5
3
  function loader() {
@@ -18,12 +16,11 @@ function loader() {
18
16
  } else if (options.cssData) {
19
17
  out = Buffer.from(options.cssData, "base64").toString("utf-8");
20
18
  }
21
- if (options.cssData || options.cssPath) {
19
+ if (out) {
22
20
  return this.callback(null, out || "");
23
21
  }
24
22
  this.callback({ message: `No CSS found`, name: "missing_css" });
25
23
  }
26
- __name(loader, "loader");
27
24
  export {
28
25
  loader as default,
29
26
  extractedInfoByFile,
package/dist/jsx/index.js CHANGED
@@ -1,14 +1,12 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
1
  process.env.TAMAGUI_TARGET = process.env.TAMAGUI_TARGET || "web";
4
2
  process.env.TAMAGUI_COMPILE_PROCESS = "1";
5
3
  var src_default = require("./loader").loader;
6
- const shouldExclude = /* @__PURE__ */ __name((path, projectRoot) => {
4
+ const shouldExclude = (path, projectRoot) => {
7
5
  if (path.includes("react-native-reanimated") || path.includes("react-native-gesture-handler") || path.includes("@gorhom/portal") || path.includes(projectRoot) || path.includes("/dist/jsx/")) {
8
6
  return false;
9
7
  }
10
8
  return true;
11
- }, "shouldExclude");
9
+ };
12
10
  export {
13
11
  src_default as default,
14
12
  shouldExclude
@@ -1,5 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
1
  import {
4
2
  createExtractor,
5
3
  extractToClassNames,
@@ -12,9 +10,10 @@ const extractor = createExtractor();
12
10
  let index = 0;
13
11
  let hasPatched = false;
14
12
  process.env.TAMAGUI_TARGET = "web";
15
- function loader(source) {
16
- this.cacheable();
13
+ const loader = function loader2(sourceIn) {
14
+ this.cacheable(true);
17
15
  this.async();
16
+ const source = sourceIn.toString();
18
17
  if (!process.env.TAMAGUI_DISABLE_RNW_PATCH && !hasPatched) {
19
18
  patchReactNativeWeb();
20
19
  hasPatched = true;
@@ -33,19 +32,23 @@ function loader(source) {
33
32
  }
34
33
  const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`;
35
34
  const extracted = extractToClassNames({
36
- loader: this,
37
35
  extractor,
38
- cssLoaderPath: CSS_LOADER_PATH,
39
36
  source,
40
- threaded,
41
37
  sourcePath,
42
- cssPath,
43
38
  options,
44
39
  shouldPrintDebug
45
40
  });
46
41
  if (!extracted) {
47
42
  return this.callback(null, source);
48
43
  }
44
+ if (extracted.styles) {
45
+ const cssQuery = threaded ? `cssData=${Buffer.from(extracted.styles).toString("base64")}` : `cssPath=${cssPath}`;
46
+ const remReq = this.remainingRequest;
47
+ const importPath = `${cssPath}!=!${CSS_LOADER_PATH}?${cssQuery}!${remReq}`;
48
+ extracted.js = `${extracted.js}
49
+
50
+ require(${JSON.stringify(importPath)})`;
51
+ }
49
52
  extractedInfoByFile.set(sourcePath, extracted);
50
53
  if (!threaded) {
51
54
  if (extracted.stylesPath) {
@@ -57,8 +60,7 @@ function loader(source) {
57
60
  console.error("ERROR", err);
58
61
  return this.callback(null, source);
59
62
  }
60
- }
61
- __name(loader, "loader");
63
+ };
62
64
  export {
63
65
  loader
64
66
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tamagui-loader",
3
- "version": "1.0.1-beta.70",
3
+ "version": "1.0.1-beta.73",
4
4
  "types": "./types/index.d.ts",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
@@ -17,12 +17,12 @@
17
17
  "clean:build": "tamagui-build clean:build"
18
18
  },
19
19
  "dependencies": {
20
- "@tamagui/static": "^1.0.1-beta.70",
20
+ "@tamagui/static": "^1.0.1-beta.73",
21
21
  "fs-extra": "^9.1.0",
22
22
  "lodash": "^4.17.21"
23
23
  },
24
24
  "devDependencies": {
25
- "@tamagui/build": "^1.0.1-beta.70"
25
+ "@tamagui/build": "^1.0.1-beta.73"
26
26
  },
27
27
  "publishConfig": {
28
28
  "access": "public"
package/src/css.ts CHANGED
@@ -22,7 +22,7 @@ export default function loader(this: LoaderContext<any>) {
22
22
  // get output CSS
23
23
  out = Buffer.from(options.cssData, 'base64').toString('utf-8')
24
24
  }
25
- if (options.cssData || options.cssPath) {
25
+ if (out) {
26
26
  // use original JS sourcemap
27
27
  return this.callback(null, out || '')
28
28
  }
package/src/loader.ts CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  extractToClassNames,
5
5
  patchReactNativeWeb,
6
6
  } from '@tamagui/static'
7
- import { LoaderContext } from 'webpack'
7
+ import type { LoaderContext, RawLoaderDefinitionFunction } from 'webpack'
8
8
 
9
9
  import { extractedInfoByFile, stylePathToFilePath } from './css'
10
10
 
@@ -19,9 +19,10 @@ let hasPatched = false
19
19
 
20
20
  process.env.TAMAGUI_TARGET = 'web'
21
21
 
22
- export function loader(this: LoaderContext<any>, source: string) {
23
- this.cacheable()
22
+ export const loader: RawLoaderDefinitionFunction<TamaguiOptions> = function loader(this, sourceIn) {
23
+ this.cacheable(true)
24
24
  this.async()
25
+ const source = sourceIn.toString()
25
26
 
26
27
  if (!process.env.TAMAGUI_DISABLE_RNW_PATCH && !hasPatched) {
27
28
  patchReactNativeWeb()
@@ -54,14 +55,14 @@ export function loader(this: LoaderContext<any>, source: string) {
54
55
 
55
56
  const cssPath = threaded ? `${sourcePath}.module.css` : `${sourcePath}.${index++}.module.css`
56
57
 
58
+ // cssLoaderPath: CSS_LOADER_PATH,
59
+ // threaded,
60
+ // cssPath,
61
+
57
62
  const extracted = extractToClassNames({
58
- loader: this,
59
63
  extractor,
60
- cssLoaderPath: CSS_LOADER_PATH,
61
64
  source,
62
- threaded,
63
65
  sourcePath,
64
- cssPath,
65
66
  options,
66
67
  shouldPrintDebug,
67
68
  })
@@ -70,6 +71,16 @@ export function loader(this: LoaderContext<any>, source: string) {
70
71
  return this.callback(null, source)
71
72
  }
72
73
 
74
+ // add import to css
75
+ if (extracted.styles) {
76
+ const cssQuery = threaded
77
+ ? `cssData=${Buffer.from(extracted.styles).toString('base64')}`
78
+ : `cssPath=${cssPath}`
79
+ const remReq = this.remainingRequest
80
+ const importPath = `${cssPath}!=!${CSS_LOADER_PATH}?${cssQuery}!${remReq}`
81
+ extracted.js = `${extracted.js}\n\nrequire(${JSON.stringify(importPath)})`
82
+ }
83
+
73
84
  extractedInfoByFile.set(sourcePath, extracted)
74
85
 
75
86
  if (!threaded) {
package/types/css.d.ts CHANGED
File without changes
File without changes
package/types/index.d.ts CHANGED
File without changes
File without changes
package/types/loader.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- import { LoaderContext } from 'webpack';
2
- export declare function loader(this: LoaderContext<any>, source: string): void;
1
+ import { TamaguiOptions } from '@tamagui/static';
2
+ import type { RawLoaderDefinitionFunction } from 'webpack';
3
+ export declare const loader: RawLoaderDefinitionFunction<TamaguiOptions>;
3
4
  //# sourceMappingURL=loader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAevC,wBAAgB,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,QAgE9D"}
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAIf,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAiB,2BAA2B,EAAE,MAAM,SAAS,CAAA;AAezE,eAAO,MAAM,MAAM,EAAE,2BAA2B,CAAC,cAAc,CA2E9D,CAAA"}