tamagui-loader 1.14.9 → 1.15.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.
@@ -31,6 +31,7 @@ __export(plugin_exports, {
31
31
  TamaguiPlugin: () => TamaguiPlugin
32
32
  });
33
33
  module.exports = __toCommonJS(plugin_exports);
34
+ var import_static = require("@tamagui/static");
34
35
  class TamaguiPlugin {
35
36
  constructor(options = {
36
37
  components: ["@tamagui/core"]
@@ -40,6 +41,8 @@ class TamaguiPlugin {
40
41
  }
41
42
  apply(compiler) {
42
43
  var _a;
44
+ if (!this.options.disableWatchConfig)
45
+ (0, import_static.watchTamaguiConfig)(this.options);
43
46
  compiler.hooks.normalModuleFactory.tap(this.pluginName, (nmf) => {
44
47
  nmf.hooks.createModule.tap(
45
48
  this.pluginName,
@@ -66,7 +69,8 @@ class TamaguiPlugin {
66
69
  const mainFields = compiler.options.resolve.mainFields;
67
70
  if (mainFields) {
68
71
  compiler.options.resolve.mainFields = Array.isArray(mainFields) ? mainFields : [mainFields];
69
- mainFields.unshift("module:jsx");
72
+ if (!this.options.disableModuleJSXEntry)
73
+ mainFields.unshift("module:jsx");
70
74
  }
71
75
  if (!compiler.options.module) {
72
76
  return;
@@ -79,44 +83,45 @@ class TamaguiPlugin {
79
83
  );
80
84
  const startIndex = nextJsRules ? nextJsRules + 1 : 0;
81
85
  const existingLoader = nextJsRules ? rules[startIndex] : void 0;
82
- rules.splice(startIndex, 0, {
83
- test: this.options.test ?? /\.m?[jt]sx?$/,
84
- exclude: this.options.exclude,
85
- resolve: {
86
- fullySpecified: false
87
- },
88
- use: [
89
- ...jsLoader ? [jsLoader] : [],
90
- ...existingLoader && nextJsRules ? [].concat(existingLoader.use) : [],
91
- ...!(jsLoader || existingLoader) ? [
86
+ if (!this.options.disableEsbuildLoader)
87
+ rules.splice(startIndex, 0, {
88
+ test: this.options.test ?? /\.m?[jt]sx?$/,
89
+ exclude: this.options.exclude,
90
+ resolve: {
91
+ fullySpecified: false
92
+ },
93
+ use: [
94
+ ...jsLoader ? [jsLoader] : [],
95
+ ...existingLoader && nextJsRules ? [].concat(existingLoader.use) : [],
96
+ ...!(jsLoader || existingLoader) ? [
97
+ {
98
+ loader: require.resolve("esbuild-loader"),
99
+ options: {
100
+ target: "es2021",
101
+ keepNames: true,
102
+ loader: {
103
+ ".tsx": "tsx",
104
+ ".png": "copy",
105
+ ".jpg": "copy",
106
+ ".gif": "copy"
107
+ },
108
+ tsconfigRaw: {
109
+ module: this.options.commonjs ? "commonjs" : "esnext",
110
+ isolatedModules: true,
111
+ jsx: "preserve",
112
+ resolveJsonModule: true
113
+ }
114
+ }
115
+ }
116
+ ] : [],
92
117
  {
93
- loader: require.resolve("esbuild-loader"),
118
+ loader: require.resolve("tamagui-loader"),
94
119
  options: {
95
- target: "es2021",
96
- keepNames: true,
97
- loader: {
98
- ".tsx": "tsx",
99
- ".png": "copy",
100
- ".jpg": "copy",
101
- ".gif": "copy"
102
- },
103
- tsconfigRaw: {
104
- module: this.options.commonjs ? "commonjs" : "esnext",
105
- isolatedModules: true,
106
- jsx: "preserve",
107
- resolveJsonModule: true
108
- }
120
+ ...this.options
109
121
  }
110
122
  }
111
- ] : [],
112
- {
113
- loader: require.resolve("tamagui-loader"),
114
- options: {
115
- ...this.options
116
- }
117
- }
118
- ]
119
- });
123
+ ]
124
+ });
120
125
  }
121
126
  }
122
127
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/plugin.ts"],
4
- "sourcesContent": ["import type { TamaguiOptions } from '@tamagui/static'\nimport type { Compiler, RuleSetRule } from 'webpack'\n\ntype PluginOptions = TamaguiOptions & {\n commonjs?: boolean\n exclude?: RuleSetRule['exclude']\n test?: RuleSetRule['test']\n jsLoader?: any\n}\n\nexport class TamaguiPlugin {\n pluginName = 'TamaguiPlugin'\n\n constructor(\n public options: PluginOptions = {\n components: ['@tamagui/core'],\n }\n ) {}\n\n apply(compiler: Compiler) {\n // mark as side effect\n compiler.hooks.normalModuleFactory.tap(this.pluginName, (nmf) => {\n nmf.hooks.createModule.tap(\n this.pluginName,\n // @ts-expect-error CreateData is typed as 'object'...\n (createData: { matchResource?: string; settings: { sideEffects?: boolean } }) => {\n if (createData.matchResource?.endsWith('.tamagui.css')) {\n createData.settings.sideEffects = true\n }\n }\n )\n })\n\n compiler.options.resolve.extensions = [\n ...new Set([\n '.web.tsx',\n '.web.ts',\n '.web.js',\n '.ts',\n '.tsx',\n '.js',\n ...(compiler.options.resolve.extensions || []),\n ]),\n ]\n\n // look for compiled js with jsx intact as specified by module:jsx\n const mainFields = compiler.options.resolve.mainFields\n if (mainFields) {\n compiler.options.resolve.mainFields = Array.isArray(mainFields)\n ? mainFields\n : [mainFields]\n mainFields.unshift('module:jsx')\n }\n\n if (!compiler.options.module) {\n return\n }\n\n const { jsLoader } = this.options\n\n const existing = compiler.options.module.rules as any[]\n\n const rules =\n (existing.find((x) => (typeof x === 'object' && 'oneOf' in x ? x : null))\n ?.oneOf as any[]) ?? existing\n\n const nextJsRules = rules.findIndex(\n (x) => x?.use && x.use.loader === 'next-swc-loader' && x.issuerLayer !== 'api'\n )\n\n const startIndex = nextJsRules ? nextJsRules + 1 : 0\n const existingLoader = nextJsRules ? rules[startIndex] : undefined\n\n rules.splice(startIndex, 0, {\n test: this.options.test ?? /\\.m?[jt]sx?$/,\n exclude: this.options.exclude,\n resolve: {\n fullySpecified: false,\n },\n use: [\n ...(jsLoader ? [jsLoader] : []),\n ...(existingLoader && nextJsRules ? [].concat(existingLoader.use) : []),\n ...(!(jsLoader || existingLoader)\n ? [\n {\n loader: require.resolve('esbuild-loader'),\n options: {\n target: 'es2021',\n keepNames: true,\n loader: {\n '.tsx': 'tsx',\n '.png': 'copy',\n '.jpg': 'copy',\n '.gif': 'copy',\n },\n\n tsconfigRaw: {\n module: this.options.commonjs ? 'commonjs' : 'esnext',\n isolatedModules: true,\n jsx: 'preserve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BACG,UAAmB;AAEzB,UAAM,cAAc,MAAM;AAAA,MACxB,CAAC,OAAM,uBAAG,QAAO,EAAE,IAAI,WAAW,qBAAqB,EAAE,gBAAgB;AAAA,IAC3E;AAEA,UAAM,aAAa,cAAc,cAAc,IAAI;AACnD,UAAM,iBAAiB,cAAc,MAAM,UAAU,IAAI;AAEzD,UAAM,OAAO,YAAY,GAAG;AAAA,MAC1B,MAAM,KAAK,QAAQ,QAAQ;AAAA,MAC3B,SAAS,KAAK,QAAQ;AAAA,MACtB,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,MACA,KAAK;AAAA,QACH,GAAI,WAAW,CAAC,QAAQ,IAAI,CAAC;AAAA,QAC7B,GAAI,kBAAkB,cAAc,CAAC,EAAE,OAAO,eAAe,GAAG,IAAI,CAAC;AAAA,QACrE,GAAI,EAAE,YAAY,kBACd;AAAA,UACE;AAAA,YACE,QAAQ,gBAAgB,gBAAgB;AAAA,YACxC,SAAS;AAAA,cACP,QAAQ;AAAA,cACR,WAAW;AAAA,cACX,QAAQ;AAAA,gBACN,QAAQ;AAAA,gBACR,QAAQ;AAAA,gBACR,QAAQ;AAAA,gBACR,QAAQ;AAAA,cACV;AAAA,cAEA,aAAa;AAAA,gBACX,QAAQ,KAAK,QAAQ,WAAW,aAAa;AAAA,gBAC7C,iBAAiB;AAAA,gBACjB,KAAK;AAAA,gBACL,mBAAmB;AAAA,cACrB;AAAA,YACF;AAAA,UACF;AAAA,QACF,IACA,CAAC;AAAA,QACL;AAAA,UACE,QAAQ,gBAAgB,gBAAgB;AAAA,UACxC,SAAS;AAAA,YACP,GAAG,KAAK;AAAA,UACV;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF;",
4
+ "sourcesContent": ["import { TamaguiOptions, watchTamaguiConfig } from '@tamagui/static'\nimport type { Compiler, RuleSetRule } from 'webpack'\n\ntype PluginOptions = TamaguiOptions & {\n commonjs?: boolean\n exclude?: RuleSetRule['exclude']\n test?: RuleSetRule['test']\n jsLoader?: any\n disableEsbuildLoader?: boolean\n disableModuleJSXEntry?: boolean\n disableWatchConfig?: boolean\n}\n\nexport class TamaguiPlugin {\n pluginName = 'TamaguiPlugin'\n\n constructor(\n public options: PluginOptions = {\n components: ['@tamagui/core'],\n }\n ) {}\n\n apply(compiler: Compiler) {\n if (!this.options.disableWatchConfig) watchTamaguiConfig(this.options)\n\n // mark as side effect\n compiler.hooks.normalModuleFactory.tap(this.pluginName, (nmf) => {\n nmf.hooks.createModule.tap(\n this.pluginName,\n // @ts-expect-error CreateData is typed as 'object'...\n (createData: { matchResource?: string; settings: { sideEffects?: boolean } }) => {\n if (createData.matchResource?.endsWith('.tamagui.css')) {\n createData.settings.sideEffects = true\n }\n }\n )\n })\n\n compiler.options.resolve.extensions = [\n ...new Set([\n '.web.tsx',\n '.web.ts',\n '.web.js',\n '.ts',\n '.tsx',\n '.js',\n ...(compiler.options.resolve.extensions || []),\n ]),\n ]\n\n // look for compiled js with jsx intact as specified by module:jsx\n const mainFields = compiler.options.resolve.mainFields\n if (mainFields) {\n compiler.options.resolve.mainFields = Array.isArray(mainFields)\n ? mainFields\n : [mainFields]\n if (!this.options.disableModuleJSXEntry) mainFields.unshift('module:jsx')\n }\n\n if (!compiler.options.module) {\n return\n }\n\n const { jsLoader } = this.options\n\n const existing = compiler.options.module.rules as any[]\n\n const rules =\n (existing.find((x) => (typeof x === 'object' && 'oneOf' in x ? x : null))\n ?.oneOf as any[]) ?? existing\n\n const nextJsRules = rules.findIndex(\n (x) => x?.use && x.use.loader === 'next-swc-loader' && x.issuerLayer !== 'api'\n )\n\n const startIndex = nextJsRules ? nextJsRules + 1 : 0\n const existingLoader = nextJsRules ? rules[startIndex] : undefined\n\n if (!this.options.disableEsbuildLoader)\n rules.splice(startIndex, 0, {\n test: this.options.test ?? /\\.m?[jt]sx?$/,\n exclude: this.options.exclude,\n resolve: {\n fullySpecified: false,\n },\n use: [\n ...(jsLoader ? [jsLoader] : []),\n ...(existingLoader && nextJsRules ? [].concat(existingLoader.use) : []),\n ...(!(jsLoader || existingLoader)\n ? [\n {\n loader: require.resolve('esbuild-loader'),\n options: {\n target: 'es2021',\n keepNames: true,\n loader: {\n '.tsx': 'tsx',\n '.png': 'copy',\n '.jpg': 'copy',\n '.gif': 'copy',\n },\n\n tsconfigRaw: {\n module: this.options.commonjs ? 'commonjs' : 'esnext',\n isolatedModules: true,\n jsx: 'preserve',\n resolveJsonModule: true,\n },\n },\n },\n ]\n : []),\n {\n loader: require.resolve('tamagui-loader'),\n options: {\n ...this.options,\n },\n },\n ],\n })\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAmD;AAa5C,MAAM,cAAc;AAAA,EAGzB,YACS,UAAyB;AAAA,IAC9B,YAAY,CAAC,eAAe;AAAA,EAC9B,GACA;AAHO;AAHT,sBAAa;AAAA,EAMV;AAAA,EAEH,MAAM,UAAoB;AAtB5B;AAuBI,QAAI,CAAC,KAAK,QAAQ;AAAoB,4CAAmB,KAAK,OAAO;AAGrE,aAAS,MAAM,oBAAoB,IAAI,KAAK,YAAY,CAAC,QAAQ;AAC/D,UAAI,MAAM,aAAa;AAAA,QACrB,KAAK;AAAA;AAAA,QAEL,CAAC,eAAgF;AA9BzF,cAAAA;AA+BU,eAAIA,MAAA,WAAW,kBAAX,gBAAAA,IAA0B,SAAS,iBAAiB;AACtD,uBAAW,SAAS,cAAc;AAAA,UACpC;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAED,aAAS,QAAQ,QAAQ,aAAa;AAAA,MACpC,GAAG,oBAAI,IAAI;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,GAAI,SAAS,QAAQ,QAAQ,cAAc,CAAC;AAAA,MAC9C,CAAC;AAAA,IACH;AAGA,UAAM,aAAa,SAAS,QAAQ,QAAQ;AAC5C,Q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AC7C,iBAAiB;AAAA,kBACjB,KAAK;AAAA,kBACL,mBAAmB;AAAA,gBACrB;AAAA,cACF;AAAA,YACF;AAAA,UACF,IACA,CAAC;AAAA,UACL;AAAA,YACE,QAAQ,gBAAgB,gBAAgB;AAAA,YACxC,SAAS;AAAA,cACP,GAAG,KAAK;AAAA,YACV;AAAA,UACF;AAAA,QACF;AAAA,MACF,CAAC;AAAA,EACL;AACF;",
6
6
  "names": ["_a"]
7
7
  }
@@ -1,3 +1,4 @@
1
+ import { watchTamaguiConfig } from "@tamagui/static";
1
2
  class TamaguiPlugin {
2
3
  constructor(options = {
3
4
  components: ["@tamagui/core"]
@@ -7,6 +8,8 @@ class TamaguiPlugin {
7
8
  }
8
9
  apply(compiler) {
9
10
  var _a;
11
+ if (!this.options.disableWatchConfig)
12
+ watchTamaguiConfig(this.options);
10
13
  compiler.hooks.normalModuleFactory.tap(this.pluginName, (nmf) => {
11
14
  nmf.hooks.createModule.tap(
12
15
  this.pluginName,
@@ -33,7 +36,8 @@ class TamaguiPlugin {
33
36
  const mainFields = compiler.options.resolve.mainFields;
34
37
  if (mainFields) {
35
38
  compiler.options.resolve.mainFields = Array.isArray(mainFields) ? mainFields : [mainFields];
36
- mainFields.unshift("module:jsx");
39
+ if (!this.options.disableModuleJSXEntry)
40
+ mainFields.unshift("module:jsx");
37
41
  }
38
42
  if (!compiler.options.module) {
39
43
  return;
@@ -46,44 +50,45 @@ class TamaguiPlugin {
46
50
  );
47
51
  const startIndex = nextJsRules ? nextJsRules + 1 : 0;
48
52
  const existingLoader = nextJsRules ? rules[startIndex] : void 0;
49
- rules.splice(startIndex, 0, {
50
- test: this.options.test ?? /\.m?[jt]sx?$/,
51
- exclude: this.options.exclude,
52
- resolve: {
53
- fullySpecified: false
54
- },
55
- use: [
56
- ...jsLoader ? [jsLoader] : [],
57
- ...existingLoader && nextJsRules ? [].concat(existingLoader.use) : [],
58
- ...!(jsLoader || existingLoader) ? [
53
+ if (!this.options.disableEsbuildLoader)
54
+ rules.splice(startIndex, 0, {
55
+ test: this.options.test ?? /\.m?[jt]sx?$/,
56
+ exclude: this.options.exclude,
57
+ resolve: {
58
+ fullySpecified: false
59
+ },
60
+ use: [
61
+ ...jsLoader ? [jsLoader] : [],
62
+ ...existingLoader && nextJsRules ? [].concat(existingLoader.use) : [],
63
+ ...!(jsLoader || existingLoader) ? [
64
+ {
65
+ loader: require.resolve("esbuild-loader"),
66
+ options: {
67
+ target: "es2021",
68
+ keepNames: true,
69
+ loader: {
70
+ ".tsx": "tsx",
71
+ ".png": "copy",
72
+ ".jpg": "copy",
73
+ ".gif": "copy"
74
+ },
75
+ tsconfigRaw: {
76
+ module: this.options.commonjs ? "commonjs" : "esnext",
77
+ isolatedModules: true,
78
+ jsx: "preserve",
79
+ resolveJsonModule: true
80
+ }
81
+ }
82
+ }
83
+ ] : [],
59
84
  {
60
- loader: require.resolve("esbuild-loader"),
85
+ loader: require.resolve("tamagui-loader"),
61
86
  options: {
62
- target: "es2021",
63
- keepNames: true,
64
- loader: {
65
- ".tsx": "tsx",
66
- ".png": "copy",
67
- ".jpg": "copy",
68
- ".gif": "copy"
69
- },
70
- tsconfigRaw: {
71
- module: this.options.commonjs ? "commonjs" : "esnext",
72
- isolatedModules: true,
73
- jsx: "preserve",
74
- resolveJsonModule: true
75
- }
87
+ ...this.options
76
88
  }
77
89
  }
78
- ] : [],
79
- {
80
- loader: require.resolve("tamagui-loader"),
81
- options: {
82
- ...this.options
83
- }
84
- }
85
- ]
86
- });
90
+ ]
91
+ });
87
92
  }
88
93
  }
89
94
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/plugin.ts"],
4
- "sourcesContent": ["import type { TamaguiOptions } from '@tamagui/static'\nimport type { Compiler, RuleSetRule } from 'webpack'\n\ntype PluginOptions = TamaguiOptions & {\n commonjs?: boolean\n exclude?: RuleSetRule['exclude']\n test?: RuleSetRule['test']\n jsLoader?: any\n}\n\nexport class TamaguiPlugin {\n pluginName = 'TamaguiPlugin'\n\n constructor(\n public options: PluginOptions = {\n components: ['@tamagui/core'],\n }\n ) {}\n\n apply(compiler: Compiler) {\n // mark as side effect\n compiler.hooks.normalModuleFactory.tap(this.pluginName, (nmf) => {\n nmf.hooks.createModule.tap(\n this.pluginName,\n // @ts-expect-error CreateData is typed as 'object'...\n (createData: { matchResource?: string; settings: { sideEffects?: boolean } }) => {\n if (createData.matchResource?.endsWith('.tamagui.css')) {\n createData.settings.sideEffects = true\n }\n }\n )\n })\n\n compiler.options.resolve.extensions = [\n ...new Set([\n '.web.tsx',\n '.web.ts',\n '.web.js',\n '.ts',\n '.tsx',\n '.js',\n ...(compiler.options.resolve.extensions || []),\n ]),\n ]\n\n // look for compiled js with jsx intact as specified by module:jsx\n const mainFields = compiler.options.resolve.mainFields\n if (mainFields) {\n compiler.options.resolve.mainFields = Array.isArray(mainFields)\n ? mainFields\n : [mainFields]\n mainFields.unshift('module:jsx')\n }\n\n if (!compiler.options.module) {\n return\n }\n\n const { jsLoader } = this.options\n\n const existing = compiler.options.module.rules as any[]\n\n const rules =\n (existing.find((x) => (typeof x === 'object' && 'oneOf' in x ? x : null))\n ?.oneOf as any[]) ?? existing\n\n const nextJsRules = rules.findIndex(\n (x) => x?.use && x.use.loader === 'next-swc-loader' && x.issuerLayer !== 'api'\n )\n\n const startIndex = nextJsRules ? nextJsRules + 1 : 0\n const existingLoader = nextJsRules ? rules[startIndex] : undefined\n\n rules.splice(startIndex, 0, {\n test: this.options.test ?? /\\.m?[jt]sx?$/,\n exclude: this.options.exclude,\n resolve: {\n fullySpecified: false,\n },\n use: [\n ...(jsLoader ? [jsLoader] : []),\n ...(existingLoader && nextJsRules ? [].concat(existingLoader.use) : []),\n ...(!(jsLoader || existingLoader)\n ? [\n {\n loader: require.resolve('esbuild-loader'),\n options: {\n target: 'es2021',\n keepNames: true,\n loader: {\n '.tsx': 'tsx',\n '.png': 'copy',\n '.jpg': 'copy',\n '.gif': 'copy',\n },\n\n tsconfigRaw: {\n module: this.options.commonjs ? 'commonjs' : 'esnext',\n isolatedModules: true,\n jsx: 'preserve',\n resolveJsonModule: true,\n },\n },\n },\n ]\n : []),\n {\n loader: require.resolve('tamagui-loader'),\n options: {\n ...this.options,\n },\n },\n ],\n })\n }\n}\n"],
5
- "mappings": "AAUO,MAAM,cAAc;AAAA,EAGzB,YACS,UAAyB;AAAA,IAC9B,YAAY,CAAC,eAAe;AAAA,EAC9B,GACA;AAHO;AAHT,sBAAa;AAAA,EAMV;AAAA,EAEH,MAAM,UAAoB;AAnB5B;AAqBI,aAAS,MAAM,oBAAoB,IAAI,KAAK,YAAY,CAAC,QAAQ;AAC/D,UAAI,MAAM,aAAa;AAAA,QACrB,KAAK;AAAA;AAAA,QAEL,CAAC,eAAgF;AAzBzF,cAAAA;AA0BU,eAAIA,MAAA,WAAW,kBAAX,gBAAAA,IAA0B,SAAS,iBAAiB;AACtD,uBAAW,SAAS,cAAc;AAAA,UACpC;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAED,aAAS,QAAQ,QAAQ,aAAa;AAAA,MACpC,GAAG,oBAAI,IAAI;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,GAAI,SAAS,QAAQ,QAAQ,cAAc,CAAC;AAAA,MAC9C,CAAC;AAAA,IACH;AAGA,UAAM,aAAa,SAAS,QAAQ,QAAQ;AAC5C,QAAI,YAAY;AACd,eAAS,QAAQ,QAAQ,aAAa,MAAM,QAAQ,UAAU,IAC1D,aACA,CAAC,UAAU;AACf,iBAAW,QAAQ,YAAY;AAAA,IACjC;AAEA,QAAI,CAAC,SAAS,QAAQ,QAAQ;AAC5B;AAAA,IACF;AAEA,UAAM,EAAE,SAAS,IAAI,KAAK;AAE1B,UAAM,WAAW,SAAS,QAAQ,OAAO;AAEzC,UAAM,UACH,cAAS,KAAK,CAAC,MAAO,OAAO,MAAM,YAAY,WAAW,IAAI,IAAI,IAAK,MAAvE,mBACG,UAAmB;AAEzB,UAAM,cAAc,MAAM;AAAA,MACxB,CAAC,OAAM,uBAAG,QAAO,EAAE,IAAI,WAAW,qBAAqB,EAAE,gBAAgB;AAAA,IAC3E;AAEA,UAAM,aAAa,cAAc,cAAc,IAAI;AACnD,UAAM,iBAAiB,cAAc,MAAM,UAAU,IAAI;AAEzD,UAAM,OAAO,YAAY,GAAG;AAAA,MAC1B,MAAM,KAAK,QAAQ,QAAQ;AAAA,MAC3B,SAAS,KAAK,QAAQ;AAAA,MACtB,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,MACA,KAAK;AAAA,QACH,GAAI,WAAW,CAAC,QAAQ,IAAI,CAAC;AAAA,QAC7B,GAAI,kBAAkB,cAAc,CAAC,EAAE,OAAO,eAAe,GAAG,IAAI,CAAC;AAAA,QACrE,GAAI,EAAE,YAAY,kBACd;AAAA,UACE;AAAA,YACE,QAAQ,gBAAgB,gBAAgB;AAAA,YACxC,SAAS;AAAA,cACP,QAAQ;AAAA,cACR,WAAW;AAAA,cACX,QAAQ;AAAA,gBACN,QAAQ;AAAA,gBACR,QAAQ;AAAA,gBACR,QAAQ;AAAA,gBACR,QAAQ;AAAA,cACV;AAAA,cAEA,aAAa;AAAA,gBACX,QAAQ,KAAK,QAAQ,WAAW,aAAa;AAAA,gBAC7C,iBAAiB;AAAA,gBACjB,KAAK;AAAA,gBACL,mBAAmB;AAAA,cACrB;AAAA,YACF;AAAA,UACF;AAAA,QACF,IACA,CAAC;AAAA,QACL;AAAA,UACE,QAAQ,gBAAgB,gBAAgB;AAAA,UACxC,SAAS;AAAA,YACP,GAAG,KAAK;AAAA,UACV;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF;",
4
+ "sourcesContent": ["import { TamaguiOptions, watchTamaguiConfig } from '@tamagui/static'\nimport type { Compiler, RuleSetRule } from 'webpack'\n\ntype PluginOptions = TamaguiOptions & {\n commonjs?: boolean\n exclude?: RuleSetRule['exclude']\n test?: RuleSetRule['test']\n jsLoader?: any\n disableEsbuildLoader?: boolean\n disableModuleJSXEntry?: boolean\n disableWatchConfig?: boolean\n}\n\nexport class TamaguiPlugin {\n pluginName = 'TamaguiPlugin'\n\n constructor(\n public options: PluginOptions = {\n components: ['@tamagui/core'],\n }\n ) {}\n\n apply(compiler: Compiler) {\n if (!this.options.disableWatchConfig) watchTamaguiConfig(this.options)\n\n // mark as side effect\n compiler.hooks.normalModuleFactory.tap(this.pluginName, (nmf) => {\n nmf.hooks.createModule.tap(\n this.pluginName,\n // @ts-expect-error CreateData is typed as 'object'...\n (createData: { matchResource?: string; settings: { sideEffects?: boolean } }) => {\n if (createData.matchResource?.endsWith('.tamagui.css')) {\n createData.settings.sideEffects = true\n }\n }\n )\n })\n\n compiler.options.resolve.extensions = [\n ...new Set([\n '.web.tsx',\n '.web.ts',\n '.web.js',\n '.ts',\n '.tsx',\n '.js',\n ...(compiler.options.resolve.extensions || []),\n ]),\n ]\n\n // look for compiled js with jsx intact as specified by module:jsx\n const mainFields = compiler.options.resolve.mainFields\n if (mainFields) {\n compiler.options.resolve.mainFields = Array.isArray(mainFields)\n ? mainFields\n : [mainFields]\n if (!this.options.disableModuleJSXEntry) mainFields.unshift('module:jsx')\n }\n\n if (!compiler.options.module) {\n return\n }\n\n const { jsLoader } = this.options\n\n const existing = compiler.options.module.rules as any[]\n\n const rules =\n (existing.find((x) => (typeof x === 'object' && 'oneOf' in x ? x : null))\n ?.oneOf as any[]) ?? existing\n\n const nextJsRules = rules.findIndex(\n (x) => x?.use && x.use.loader === 'next-swc-loader' && x.issuerLayer !== 'api'\n )\n\n const startIndex = nextJsRules ? nextJsRules + 1 : 0\n const existingLoader = nextJsRules ? rules[startIndex] : undefined\n\n if (!this.options.disableEsbuildLoader)\n rules.splice(startIndex, 0, {\n test: this.options.test ?? /\\.m?[jt]sx?$/,\n exclude: this.options.exclude,\n resolve: {\n fullySpecified: false,\n },\n use: [\n ...(jsLoader ? [jsLoader] : []),\n ...(existingLoader && nextJsRules ? [].concat(existingLoader.use) : []),\n ...(!(jsLoader || existingLoader)\n ? [\n {\n loader: require.resolve('esbuild-loader'),\n options: {\n target: 'es2021',\n keepNames: true,\n loader: {\n '.tsx': 'tsx',\n '.png': 'copy',\n '.jpg': 'copy',\n '.gif': 'copy',\n },\n\n tsconfigRaw: {\n module: this.options.commonjs ? 'commonjs' : 'esnext',\n isolatedModules: true,\n jsx: 'preserve',\n resolveJsonModule: true,\n },\n },\n },\n ]\n : []),\n {\n loader: require.resolve('tamagui-loader'),\n options: {\n ...this.options,\n },\n },\n ],\n })\n }\n}\n"],
5
+ "mappings": "AAAA,SAAyB,0BAA0B;AAa5C,MAAM,cAAc;AAAA,EAGzB,YACS,UAAyB;AAAA,IAC9B,YAAY,CAAC,eAAe;AAAA,EAC9B,GACA;AAHO;AAHT,sBAAa;AAAA,EAMV;AAAA,EAEH,MAAM,UAAoB;AAtB5B;AAuBI,QAAI,CAAC,KAAK,QAAQ;AAAoB,yBAAmB,KAAK,OAAO;AAGrE,aAAS,MAAM,oBAAoB,IAAI,KAAK,YAAY,CAAC,QAAQ;AAC/D,UAAI,MAAM,aAAa;AAAA,QACrB,KAAK;AAAA;AAAA,QAEL,CAAC,eAAgF;AA9BzF,cAAAA;AA+BU,eAAIA,MAAA,WAAW,kBAAX,gBAAAA,IAA0B,SAAS,iBAAiB;AACtD,uBAAW,SAAS,cAAc;AAAA,UACpC;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAED,aAAS,QAAQ,QAAQ,aAAa;AAAA,MACpC,GAAG,oBAAI,IAAI;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,GAAI,SAAS,QAAQ,QAAQ,cAAc,CAAC;AAAA,MAC9C,CAAC;AAAA,IACH;AAGA,UAAM,aAAa,SAAS,QAAQ,QAAQ;AAC5C,QAAI,YAAY;AACd,eAAS,QAAQ,QAAQ,aAAa,MAAM,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AAmB;AAAA,gBACrB;AAAA,cACF;AAAA,YACF;AAAA,UACF,IACA,CAAC;AAAA,UACL;AAAA,YACE,QAAQ,gBAAgB,gBAAgB;AAAA,YACxC,SAAS;AAAA,cACP,GAAG,KAAK;AAAA,YACV;AAAA,UACF;AAAA,QACF;AAAA,MACF,CAAC;AAAA,EACL;AACF;",
6
6
  "names": ["_a"]
7
7
  }
@@ -1,3 +1,4 @@
1
+ import { watchTamaguiConfig } from "@tamagui/static";
1
2
  class TamaguiPlugin {
2
3
  constructor(options = {
3
4
  components: ["@tamagui/core"]
@@ -7,6 +8,8 @@ class TamaguiPlugin {
7
8
  }
8
9
  apply(compiler) {
9
10
  var _a;
11
+ if (!this.options.disableWatchConfig)
12
+ watchTamaguiConfig(this.options);
10
13
  compiler.hooks.normalModuleFactory.tap(this.pluginName, (nmf) => {
11
14
  nmf.hooks.createModule.tap(
12
15
  this.pluginName,
@@ -33,7 +36,8 @@ class TamaguiPlugin {
33
36
  const mainFields = compiler.options.resolve.mainFields;
34
37
  if (mainFields) {
35
38
  compiler.options.resolve.mainFields = Array.isArray(mainFields) ? mainFields : [mainFields];
36
- mainFields.unshift("module:jsx");
39
+ if (!this.options.disableModuleJSXEntry)
40
+ mainFields.unshift("module:jsx");
37
41
  }
38
42
  if (!compiler.options.module) {
39
43
  return;
@@ -46,44 +50,45 @@ class TamaguiPlugin {
46
50
  );
47
51
  const startIndex = nextJsRules ? nextJsRules + 1 : 0;
48
52
  const existingLoader = nextJsRules ? rules[startIndex] : void 0;
49
- rules.splice(startIndex, 0, {
50
- test: this.options.test ?? /\.m?[jt]sx?$/,
51
- exclude: this.options.exclude,
52
- resolve: {
53
- fullySpecified: false
54
- },
55
- use: [
56
- ...jsLoader ? [jsLoader] : [],
57
- ...existingLoader && nextJsRules ? [].concat(existingLoader.use) : [],
58
- ...!(jsLoader || existingLoader) ? [
53
+ if (!this.options.disableEsbuildLoader)
54
+ rules.splice(startIndex, 0, {
55
+ test: this.options.test ?? /\.m?[jt]sx?$/,
56
+ exclude: this.options.exclude,
57
+ resolve: {
58
+ fullySpecified: false
59
+ },
60
+ use: [
61
+ ...jsLoader ? [jsLoader] : [],
62
+ ...existingLoader && nextJsRules ? [].concat(existingLoader.use) : [],
63
+ ...!(jsLoader || existingLoader) ? [
64
+ {
65
+ loader: require.resolve("esbuild-loader"),
66
+ options: {
67
+ target: "es2021",
68
+ keepNames: true,
69
+ loader: {
70
+ ".tsx": "tsx",
71
+ ".png": "copy",
72
+ ".jpg": "copy",
73
+ ".gif": "copy"
74
+ },
75
+ tsconfigRaw: {
76
+ module: this.options.commonjs ? "commonjs" : "esnext",
77
+ isolatedModules: true,
78
+ jsx: "preserve",
79
+ resolveJsonModule: true
80
+ }
81
+ }
82
+ }
83
+ ] : [],
59
84
  {
60
- loader: require.resolve("esbuild-loader"),
85
+ loader: require.resolve("tamagui-loader"),
61
86
  options: {
62
- target: "es2021",
63
- keepNames: true,
64
- loader: {
65
- ".tsx": "tsx",
66
- ".png": "copy",
67
- ".jpg": "copy",
68
- ".gif": "copy"
69
- },
70
- tsconfigRaw: {
71
- module: this.options.commonjs ? "commonjs" : "esnext",
72
- isolatedModules: true,
73
- jsx: "preserve",
74
- resolveJsonModule: true
75
- }
87
+ ...this.options
76
88
  }
77
89
  }
78
- ] : [],
79
- {
80
- loader: require.resolve("tamagui-loader"),
81
- options: {
82
- ...this.options
83
- }
84
- }
85
- ]
86
- });
90
+ ]
91
+ });
87
92
  }
88
93
  }
89
94
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/plugin.ts"],
4
- "sourcesContent": ["import type { TamaguiOptions } from '@tamagui/static'\nimport type { Compiler, RuleSetRule } from 'webpack'\n\ntype PluginOptions = TamaguiOptions & {\n commonjs?: boolean\n exclude?: RuleSetRule['exclude']\n test?: RuleSetRule['test']\n jsLoader?: any\n}\n\nexport class TamaguiPlugin {\n pluginName = 'TamaguiPlugin'\n\n constructor(\n public options: PluginOptions = {\n components: ['@tamagui/core'],\n }\n ) {}\n\n apply(compiler: Compiler) {\n // mark as side effect\n compiler.hooks.normalModuleFactory.tap(this.pluginName, (nmf) => {\n nmf.hooks.createModule.tap(\n this.pluginName,\n // @ts-expect-error CreateData is typed as 'object'...\n (createData: { matchResource?: string; settings: { sideEffects?: boolean } }) => {\n if (createData.matchResource?.endsWith('.tamagui.css')) {\n createData.settings.sideEffects = true\n }\n }\n )\n })\n\n compiler.options.resolve.extensions = [\n ...new Set([\n '.web.tsx',\n '.web.ts',\n '.web.js',\n '.ts',\n '.tsx',\n '.js',\n ...(compiler.options.resolve.extensions || []),\n ]),\n ]\n\n // look for compiled js with jsx intact as specified by module:jsx\n const mainFields = compiler.options.resolve.mainFields\n if (mainFields) {\n compiler.options.resolve.mainFields = Array.isArray(mainFields)\n ? mainFields\n : [mainFields]\n mainFields.unshift('module:jsx')\n }\n\n if (!compiler.options.module) {\n return\n }\n\n const { jsLoader } = this.options\n\n const existing = compiler.options.module.rules as any[]\n\n const rules =\n (existing.find((x) => (typeof x === 'object' && 'oneOf' in x ? x : null))\n ?.oneOf as any[]) ?? existing\n\n const nextJsRules = rules.findIndex(\n (x) => x?.use && x.use.loader === 'next-swc-loader' && x.issuerLayer !== 'api'\n )\n\n const startIndex = nextJsRules ? nextJsRules + 1 : 0\n const existingLoader = nextJsRules ? rules[startIndex] : undefined\n\n rules.splice(startIndex, 0, {\n test: this.options.test ?? /\\.m?[jt]sx?$/,\n exclude: this.options.exclude,\n resolve: {\n fullySpecified: false,\n },\n use: [\n ...(jsLoader ? [jsLoader] : []),\n ...(existingLoader && nextJsRules ? [].concat(existingLoader.use) : []),\n ...(!(jsLoader || existingLoader)\n ? [\n {\n loader: require.resolve('esbuild-loader'),\n options: {\n target: 'es2021',\n keepNames: true,\n loader: {\n '.tsx': 'tsx',\n '.png': 'copy',\n '.jpg': 'copy',\n '.gif': 'copy',\n },\n\n tsconfigRaw: {\n module: this.options.commonjs ? 'commonjs' : 'esnext',\n isolatedModules: true,\n jsx: 'preserve',\n resolveJsonModule: true,\n },\n },\n },\n ]\n : []),\n {\n loader: require.resolve('tamagui-loader'),\n options: {\n ...this.options,\n },\n },\n ],\n })\n }\n}\n"],
5
- "mappings": "AAUO,MAAM,cAAc;AAAA,EAGzB,YACS,UAAyB;AAAA,IAC9B,YAAY,CAAC,eAAe;AAAA,EAC9B,GACA;AAHO;AAHT,sBAAa;AAAA,EAMV;AAAA,EAEH,MAAM,UAAoB;AAnB5B;AAqBI,aAAS,MAAM,oBAAoB,IAAI,KAAK,YAAY,CAAC,QAAQ;AAC/D,UAAI,MAAM,aAAa;AAAA,QACrB,KAAK;AAAA;AAAA,QAEL,CAAC,eAAgF;AAzBzF,cAAAA;AA0BU,eAAIA,MAAA,WAAW,kBAAX,gBAAAA,IAA0B,SAAS,iBAAiB;AACtD,uBAAW,SAAS,cAAc;AAAA,UACpC;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAED,aAAS,QAAQ,QAAQ,aAAa;AAAA,MACpC,GAAG,oBAAI,IAAI;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,GAAI,SAAS,QAAQ,QAAQ,cAAc,CAAC;AAAA,MAC9C,CAAC;AAAA,IACH;AAGA,UAAM,aAAa,SAAS,QAAQ,QAAQ;AAC5C,QAAI,YAAY;AACd,eAAS,QAAQ,QAAQ,aAAa,MAAM,QAAQ,UAAU,IAC1D,aACA,CAAC,UAAU;AACf,iBAAW,QAAQ,YAAY;AAAA,IACjC;AAEA,QAAI,CAAC,SAAS,QAAQ,QAAQ;AAC5B;AAAA,IACF;AAEA,UAAM,EAAE,SAAS,IAAI,KAAK;AAE1B,UAAM,WAAW,SAAS,QAAQ,OAAO;AAEzC,UAAM,UACH,cAAS,KAAK,CAAC,MAAO,OAAO,MAAM,YAAY,WAAW,IAAI,IAAI,IAAK,MAAvE,mBACG,UAAmB;AAEzB,UAAM,cAAc,MAAM;AAAA,MACxB,CAAC,OAAM,uBAAG,QAAO,EAAE,IAAI,WAAW,qBAAqB,EAAE,gBAAgB;AAAA,IAC3E;AAEA,UAAM,aAAa,cAAc,cAAc,IAAI;AACnD,UAAM,iBAAiB,cAAc,MAAM,UAAU,IAAI;AAEzD,UAAM,OAAO,YAAY,GAAG;AAAA,MAC1B,MAAM,KAAK,QAAQ,QAAQ;AAAA,MAC3B,SAAS,KAAK,QAAQ;AAAA,MACtB,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,MACA,KAAK;AAAA,QACH,GAAI,WAAW,CAAC,QAAQ,IAAI,CAAC;AAAA,QAC7B,GAAI,kBAAkB,cAAc,CAAC,EAAE,OAAO,eAAe,GAAG,IAAI,CAAC;AAAA,QACrE,GAAI,EAAE,YAAY,kBACd;AAAA,UACE;AAAA,YACE,QAAQ,gBAAgB,gBAAgB;AAAA,YACxC,SAAS;AAAA,cACP,QAAQ;AAAA,cACR,WAAW;AAAA,cACX,QAAQ;AAAA,gBACN,QAAQ;AAAA,gBACR,QAAQ;AAAA,gBACR,QAAQ;AAAA,gBACR,QAAQ;AAAA,cACV;AAAA,cAEA,aAAa;AAAA,gBACX,QAAQ,KAAK,QAAQ,WAAW,aAAa;AAAA,gBAC7C,iBAAiB;AAAA,gBACjB,KAAK;AAAA,gBACL,mBAAmB;AAAA,cACrB;AAAA,YACF;AAAA,UACF;AAAA,QACF,IACA,CAAC;AAAA,QACL;AAAA,UACE,QAAQ,gBAAgB,gBAAgB;AAAA,UACxC,SAAS;AAAA,YACP,GAAG,KAAK;AAAA,UACV;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF;",
4
+ "sourcesContent": ["import { TamaguiOptions, watchTamaguiConfig } from '@tamagui/static'\nimport type { Compiler, RuleSetRule } from 'webpack'\n\ntype PluginOptions = TamaguiOptions & {\n commonjs?: boolean\n exclude?: RuleSetRule['exclude']\n test?: RuleSetRule['test']\n jsLoader?: any\n disableEsbuildLoader?: boolean\n disableModuleJSXEntry?: boolean\n disableWatchConfig?: boolean\n}\n\nexport class TamaguiPlugin {\n pluginName = 'TamaguiPlugin'\n\n constructor(\n public options: PluginOptions = {\n components: ['@tamagui/core'],\n }\n ) {}\n\n apply(compiler: Compiler) {\n if (!this.options.disableWatchConfig) watchTamaguiConfig(this.options)\n\n // mark as side effect\n compiler.hooks.normalModuleFactory.tap(this.pluginName, (nmf) => {\n nmf.hooks.createModule.tap(\n this.pluginName,\n // @ts-expect-error CreateData is typed as 'object'...\n (createData: { matchResource?: string; settings: { sideEffects?: boolean } }) => {\n if (createData.matchResource?.endsWith('.tamagui.css')) {\n createData.settings.sideEffects = true\n }\n }\n )\n })\n\n compiler.options.resolve.extensions = [\n ...new Set([\n '.web.tsx',\n '.web.ts',\n '.web.js',\n '.ts',\n '.tsx',\n '.js',\n ...(compiler.options.resolve.extensions || []),\n ]),\n ]\n\n // look for compiled js with jsx intact as specified by module:jsx\n const mainFields = compiler.options.resolve.mainFields\n if (mainFields) {\n compiler.options.resolve.mainFields = Array.isArray(mainFields)\n ? mainFields\n : [mainFields]\n if (!this.options.disableModuleJSXEntry) mainFields.unshift('module:jsx')\n }\n\n if (!compiler.options.module) {\n return\n }\n\n const { jsLoader } = this.options\n\n const existing = compiler.options.module.rules as any[]\n\n const rules =\n (existing.find((x) => (typeof x === 'object' && 'oneOf' in x ? x : null))\n ?.oneOf as any[]) ?? existing\n\n const nextJsRules = rules.findIndex(\n (x) => x?.use && x.use.loader === 'next-swc-loader' && x.issuerLayer !== 'api'\n )\n\n const startIndex = nextJsRules ? nextJsRules + 1 : 0\n const existingLoader = nextJsRules ? rules[startIndex] : undefined\n\n if (!this.options.disableEsbuildLoader)\n rules.splice(startIndex, 0, {\n test: this.options.test ?? /\\.m?[jt]sx?$/,\n exclude: this.options.exclude,\n resolve: {\n fullySpecified: false,\n },\n use: [\n ...(jsLoader ? [jsLoader] : []),\n ...(existingLoader && nextJsRules ? [].concat(existingLoader.use) : []),\n ...(!(jsLoader || existingLoader)\n ? [\n {\n loader: require.resolve('esbuild-loader'),\n options: {\n target: 'es2021',\n keepNames: true,\n loader: {\n '.tsx': 'tsx',\n '.png': 'copy',\n '.jpg': 'copy',\n '.gif': 'copy',\n },\n\n tsconfigRaw: {\n module: this.options.commonjs ? 'commonjs' : 'esnext',\n isolatedModules: true,\n jsx: 'preserve',\n resolveJsonModule: true,\n },\n },\n },\n ]\n : []),\n {\n loader: require.resolve('tamagui-loader'),\n options: {\n ...this.options,\n },\n },\n ],\n })\n }\n}\n"],
5
+ "mappings": "AAAA,SAAyB,0BAA0B;AAa5C,MAAM,cAAc;AAAA,EAGzB,YACS,UAAyB;AAAA,IAC9B,YAAY,CAAC,eAAe;AAAA,EAC9B,GACA;AAHO;AAHT,sBAAa;AAAA,EAMV;AAAA,EAEH,MAAM,UAAoB;AAtB5B;AAuBI,QAAI,CAAC,KAAK,QAAQ;AAAoB,yBAAmB,KAAK,OAAO;AAGrE,aAAS,MAAM,oBAAoB,IAAI,KAAK,YAAY,CAAC,QAAQ;AAC/D,UAAI,MAAM,aAAa;AAAA,QACrB,KAAK;AAAA;AAAA,QAEL,CAAC,eAAgF;AA9BzF,cAAAA;AA+BU,eAAIA,MAAA,WAAW,kBAAX,gBAAAA,IAA0B,SAAS,iBAAiB;AACtD,uBAAW,SAAS,cAAc;AAAA,UACpC;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAED,aAAS,QAAQ,QAAQ,aAAa;AAAA,MACpC,GAAG,oBAAI,IAAI;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,GAAI,SAAS,QAAQ,QAAQ,cAAc,CAAC;AAAA,MAC9C,CAAC;AAAA,IACH;AAGA,UAAM,aAAa,SAAS,QAAQ,QAAQ;AAC5C,QAAI,YAAY;AACd,eAAS,QAAQ,QAAQ,aAAa,MAAM,QAAQ,UAAU,IAC1D,aACA,CAAC,UAAU;AACf,UAAI,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ACF,IACA,CAAC;AAAA,UACL;AAAA,YACE,QAAQ,gBAAgB,gBAAgB;AAAA,YACxC,SAAS;AAAA,cACP,GAAG,KAAK;AAAA,YACV;AAAA,UACF;AAAA,QACF;AAAA,MACF,CAAC;AAAA,EACL;AACF;",
6
6
  "names": ["_a"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tamagui-loader",
3
- "version": "1.14.9",
3
+ "version": "1.15.0",
4
4
  "types": "./types/index.d.ts",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
@@ -13,19 +13,19 @@
13
13
  "build": "tamagui-build",
14
14
  "watch": "tamagui-build --watch",
15
15
  "lint": "../../node_modules/.bin/rome check src",
16
- "lint:fix": "../../node_modules/.bin/rome check --apply-suggested src",
16
+ "lint:fix": "../../node_modules/.bin/rome check --apply src",
17
17
  "clean": "tamagui-build clean",
18
18
  "clean:build": "tamagui-build clean:build"
19
19
  },
20
20
  "dependencies": {
21
- "@tamagui/cli-color": "1.14.9",
22
- "@tamagui/static": "1.14.9",
21
+ "@tamagui/cli-color": "1.15.0",
22
+ "@tamagui/static": "1.15.0",
23
23
  "fs-extra": "^11.1.0",
24
24
  "loader-utils": "^3.2.1",
25
25
  "lodash": "^4.17.21"
26
26
  },
27
27
  "devDependencies": {
28
- "@tamagui/build": "1.14.9",
28
+ "@tamagui/build": "1.15.0",
29
29
  "webpack": "^5.74.0"
30
30
  },
31
31
  "publishConfig": {
package/src/plugin.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { TamaguiOptions } from '@tamagui/static'
1
+ import { TamaguiOptions, watchTamaguiConfig } from '@tamagui/static'
2
2
  import type { Compiler, RuleSetRule } from 'webpack'
3
3
 
4
4
  type PluginOptions = TamaguiOptions & {
@@ -6,6 +6,9 @@ type PluginOptions = TamaguiOptions & {
6
6
  exclude?: RuleSetRule['exclude']
7
7
  test?: RuleSetRule['test']
8
8
  jsLoader?: any
9
+ disableEsbuildLoader?: boolean
10
+ disableModuleJSXEntry?: boolean
11
+ disableWatchConfig?: boolean
9
12
  }
10
13
 
11
14
  export class TamaguiPlugin {
@@ -18,6 +21,8 @@ export class TamaguiPlugin {
18
21
  ) {}
19
22
 
20
23
  apply(compiler: Compiler) {
24
+ if (!this.options.disableWatchConfig) watchTamaguiConfig(this.options)
25
+
21
26
  // mark as side effect
22
27
  compiler.hooks.normalModuleFactory.tap(this.pluginName, (nmf) => {
23
28
  nmf.hooks.createModule.tap(
@@ -49,7 +54,7 @@ export class TamaguiPlugin {
49
54
  compiler.options.resolve.mainFields = Array.isArray(mainFields)
50
55
  ? mainFields
51
56
  : [mainFields]
52
- mainFields.unshift('module:jsx')
57
+ if (!this.options.disableModuleJSXEntry) mainFields.unshift('module:jsx')
53
58
  }
54
59
 
55
60
  if (!compiler.options.module) {
@@ -71,46 +76,47 @@ export class TamaguiPlugin {
71
76
  const startIndex = nextJsRules ? nextJsRules + 1 : 0
72
77
  const existingLoader = nextJsRules ? rules[startIndex] : undefined
73
78
 
74
- rules.splice(startIndex, 0, {
75
- test: this.options.test ?? /\.m?[jt]sx?$/,
76
- exclude: this.options.exclude,
77
- resolve: {
78
- fullySpecified: false,
79
- },
80
- use: [
81
- ...(jsLoader ? [jsLoader] : []),
82
- ...(existingLoader && nextJsRules ? [].concat(existingLoader.use) : []),
83
- ...(!(jsLoader || existingLoader)
84
- ? [
85
- {
86
- loader: require.resolve('esbuild-loader'),
87
- options: {
88
- target: 'es2021',
89
- keepNames: true,
90
- loader: {
91
- '.tsx': 'tsx',
92
- '.png': 'copy',
93
- '.jpg': 'copy',
94
- '.gif': 'copy',
95
- },
79
+ if (!this.options.disableEsbuildLoader)
80
+ rules.splice(startIndex, 0, {
81
+ test: this.options.test ?? /\.m?[jt]sx?$/,
82
+ exclude: this.options.exclude,
83
+ resolve: {
84
+ fullySpecified: false,
85
+ },
86
+ use: [
87
+ ...(jsLoader ? [jsLoader] : []),
88
+ ...(existingLoader && nextJsRules ? [].concat(existingLoader.use) : []),
89
+ ...(!(jsLoader || existingLoader)
90
+ ? [
91
+ {
92
+ loader: require.resolve('esbuild-loader'),
93
+ options: {
94
+ target: 'es2021',
95
+ keepNames: true,
96
+ loader: {
97
+ '.tsx': 'tsx',
98
+ '.png': 'copy',
99
+ '.jpg': 'copy',
100
+ '.gif': 'copy',
101
+ },
96
102
 
97
- tsconfigRaw: {
98
- module: this.options.commonjs ? 'commonjs' : 'esnext',
99
- isolatedModules: true,
100
- jsx: 'preserve',
101
- resolveJsonModule: true,
103
+ tsconfigRaw: {
104
+ module: this.options.commonjs ? 'commonjs' : 'esnext',
105
+ isolatedModules: true,
106
+ jsx: 'preserve',
107
+ resolveJsonModule: true,
108
+ },
102
109
  },
103
110
  },
104
- },
105
- ]
106
- : []),
107
- {
108
- loader: require.resolve('tamagui-loader'),
109
- options: {
110
- ...this.options,
111
+ ]
112
+ : []),
113
+ {
114
+ loader: require.resolve('tamagui-loader'),
115
+ options: {
116
+ ...this.options,
117
+ },
111
118
  },
112
- },
113
- ],
114
- })
119
+ ],
120
+ })
115
121
  }
116
122
  }
package/types/plugin.d.ts CHANGED
@@ -1,10 +1,13 @@
1
- import type { TamaguiOptions } from '@tamagui/static';
1
+ import { TamaguiOptions } from '@tamagui/static';
2
2
  import type { Compiler, RuleSetRule } from 'webpack';
3
3
  type PluginOptions = TamaguiOptions & {
4
4
  commonjs?: boolean;
5
5
  exclude?: RuleSetRule['exclude'];
6
6
  test?: RuleSetRule['test'];
7
7
  jsLoader?: any;
8
+ disableEsbuildLoader?: boolean;
9
+ disableModuleJSXEntry?: boolean;
10
+ disableWatchConfig?: boolean;
8
11
  };
9
12
  export declare class TamaguiPlugin {
10
13
  options: PluginOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE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