@wyw-in-js/webpack-loader 0.6.0 → 0.8.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.
- package/esm/index.js +4 -2
- package/esm/index.js.map +1 -1
- package/lib/index.js +4 -2
- package/lib/index.js.map +1 -1
- package/package.json +7 -7
- package/types/index.d.ts +1 -0
- package/types/index.js +4 -3
package/esm/index.js
CHANGED
|
@@ -33,6 +33,7 @@ const webpack5Loader = function webpack5LoaderPlugin(content, inputSourceMap) {
|
|
|
33
33
|
const {
|
|
34
34
|
sourceMap = undefined,
|
|
35
35
|
preprocessor = undefined,
|
|
36
|
+
prefixer = undefined,
|
|
36
37
|
extension = '.wyw-in-js.css',
|
|
37
38
|
cacheProvider,
|
|
38
39
|
...rest
|
|
@@ -60,9 +61,10 @@ const webpack5Loader = function webpack5LoaderPlugin(content, inputSourceMap) {
|
|
|
60
61
|
options: {
|
|
61
62
|
filename: this.resourcePath,
|
|
62
63
|
inputSourceMap: convertSourceMap(inputSourceMap, this.resourcePath),
|
|
63
|
-
|
|
64
|
+
pluginOptions: rest,
|
|
65
|
+
prefixer,
|
|
64
66
|
preprocessor,
|
|
65
|
-
|
|
67
|
+
root: process.cwd()
|
|
66
68
|
},
|
|
67
69
|
cache,
|
|
68
70
|
eventEmitter: sharedState.emitter
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["path","logger","transform","TransformCacheCollection","sharedState","getCacheInstance","WYWinJSDebugPlugin","outputCssLoader","require","resolve","cache","webpack5Loader","webpack5LoaderPlugin","content","inputSourceMap","convertSourceMap","value","filename","undefined","file","mappings","names","sources","version","async","resourcePath","sourceMap","preprocessor","extension","cacheProvider","rest","getOptions","outputFileName","replace","resolveModule","getResolve","dependencyType","asyncResolve","token","importer","context","isAbsolute","dirname","join","process","cwd","Promise","reject","err","result","addDependency","Error","transformServices","options","
|
|
1
|
+
{"version":3,"file":"index.js","names":["path","logger","transform","TransformCacheCollection","sharedState","getCacheInstance","WYWinJSDebugPlugin","outputCssLoader","require","resolve","cache","webpack5Loader","webpack5LoaderPlugin","content","inputSourceMap","convertSourceMap","value","filename","undefined","file","mappings","names","sources","version","async","resourcePath","sourceMap","preprocessor","prefixer","extension","cacheProvider","rest","getOptions","outputFileName","replace","resolveModule","getResolve","dependencyType","asyncResolve","token","importer","context","isAbsolute","dirname","join","process","cwd","Promise","reject","err","result","addDependency","Error","transformServices","options","pluginOptions","root","eventEmitter","emitter","toString","then","cssText","Buffer","from","cssSourceMapText","all","dependencies","map","dep","cacheInstance","set","setDependencies","getDependencies","request","encodeURIComponent","stringifiedRequest","JSON","stringify","utils","contextify","rootContext","callback","code","catch"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * This file contains a Webpack loader for WYW-in-JS.\n * It uses the transform.ts function to generate class names from source code,\n * returns transformed code without template literals and attaches generated source maps\n */\n\nimport path from 'path';\n\nimport type { RawSourceMap } from 'source-map';\nimport type { RawLoaderDefinitionFunction } from 'webpack';\n\nimport { logger } from '@wyw-in-js/shared';\nimport type { Preprocessor, Result } from '@wyw-in-js/transform';\nimport { transform, TransformCacheCollection } from '@wyw-in-js/transform';\n\nimport { sharedState } from './WYWinJSDebugPlugin';\nimport type { ICache } from './cache';\nimport { getCacheInstance } from './cache';\n\nexport { WYWinJSDebugPlugin } from './WYWinJSDebugPlugin';\n\nconst outputCssLoader = require.resolve('./outputCssLoader');\n\nexport type LoaderOptions = {\n cacheProvider?: string | ICache;\n extension?: string;\n prefixer?: boolean;\n preprocessor?: Preprocessor;\n sourceMap?: boolean;\n};\ntype Loader = RawLoaderDefinitionFunction<LoaderOptions>;\n\nconst cache = new TransformCacheCollection();\n\nconst webpack5Loader: Loader = function webpack5LoaderPlugin(\n content,\n inputSourceMap\n) {\n function convertSourceMap(\n value: typeof inputSourceMap,\n filename: string\n ): RawSourceMap | undefined {\n if (typeof value === 'string' || !value) {\n return undefined;\n }\n\n return {\n ...value,\n file: value.file ?? filename,\n mappings: value.mappings ?? '',\n names: value.names ?? [],\n sources: value.sources ?? [],\n version: value.version ?? 3,\n };\n }\n\n // tell Webpack this loader is async\n this.async();\n\n logger('loader %s', this.resourcePath);\n\n const {\n sourceMap = undefined,\n preprocessor = undefined,\n prefixer = undefined,\n extension = '.wyw-in-js.css',\n cacheProvider,\n ...rest\n } = this.getOptions() || {};\n\n const outputFileName = this.resourcePath.replace(/\\.[^.]+$/, extension);\n const resolveModule = this.getResolve({ dependencyType: 'esm' });\n\n const asyncResolve = (token: string, importer: string): Promise<string> => {\n const context = path.isAbsolute(importer)\n ? path.dirname(importer)\n : path.join(process.cwd(), path.dirname(importer));\n return new Promise((resolve, reject) => {\n resolveModule(context, token, (err, result) => {\n if (err) {\n reject(err);\n } else if (result) {\n this.addDependency(result);\n resolve(result);\n } else {\n reject(new Error(`Cannot resolve ${token}`));\n }\n });\n });\n };\n\n const transformServices = {\n options: {\n filename: this.resourcePath,\n inputSourceMap: convertSourceMap(inputSourceMap, this.resourcePath),\n pluginOptions: rest,\n prefixer,\n preprocessor,\n root: process.cwd(),\n },\n cache,\n eventEmitter: sharedState.emitter,\n };\n\n transform(transformServices, content.toString(), asyncResolve)\n .then(\n async (result: Result) => {\n if (result.cssText) {\n let { cssText } = result;\n\n if (sourceMap) {\n cssText += `/*# sourceMappingURL=data:application/json;base64,${Buffer.from(\n result.cssSourceMapText || ''\n ).toString('base64')}*/`;\n }\n\n await Promise.all(\n result.dependencies?.map((dep) =>\n asyncResolve(dep, this.resourcePath)\n ) ?? []\n );\n\n try {\n const cacheInstance = await getCacheInstance(cacheProvider);\n\n await cacheInstance.set(this.resourcePath, cssText);\n\n await cacheInstance.setDependencies?.(\n this.resourcePath,\n this.getDependencies()\n );\n\n const request = `${outputFileName}!=!${outputCssLoader}?cacheProvider=${encodeURIComponent(\n typeof cacheProvider === 'string' ? cacheProvider : ''\n )}!${this.resourcePath}`;\n const stringifiedRequest = JSON.stringify(\n this.utils.contextify(this.context || this.rootContext, request)\n );\n\n this.callback(\n null,\n `${result.code}\\n\\nrequire(${stringifiedRequest});`,\n result.sourceMap ?? undefined\n );\n } catch (err) {\n this.callback(err as Error);\n }\n\n return;\n }\n\n this.callback(null, result.code, result.sourceMap ?? undefined);\n },\n (err: Error) => this.callback(err)\n )\n .catch((err: Error) => this.callback(err));\n};\n\nexport default webpack5Loader;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,IAAI,MAAM,MAAM;AAKvB,SAASC,MAAM,QAAQ,mBAAmB;AAE1C,SAASC,SAAS,EAAEC,wBAAwB,QAAQ,sBAAsB;AAE1E,SAASC,WAAW,QAAQ,sBAAsB;AAElD,SAASC,gBAAgB,QAAQ,SAAS;AAE1C,SAASC,kBAAkB,QAAQ,sBAAsB;AAEzD,MAAMC,eAAe,GAAGC,OAAO,CAACC,OAAO,CAAC,mBAAmB,CAAC;AAW5D,MAAMC,KAAK,GAAG,IAAIP,wBAAwB,CAAC,CAAC;AAE5C,MAAMQ,cAAsB,GAAG,SAASC,oBAAoBA,CAC1DC,OAAO,EACPC,cAAc,EACd;EACA,SAASC,gBAAgBA,CACvBC,KAA4B,EAC5BC,QAAgB,EACU;IAC1B,IAAI,OAAOD,KAAK,KAAK,QAAQ,IAAI,CAACA,KAAK,EAAE;MACvC,OAAOE,SAAS;IAClB;IAEA,OAAO;MACL,GAAGF,KAAK;MACRG,IAAI,EAAEH,KAAK,CAACG,IAAI,IAAIF,QAAQ;MAC5BG,QAAQ,EAAEJ,KAAK,CAACI,QAAQ,IAAI,EAAE;MAC9BC,KAAK,EAAEL,KAAK,CAACK,KAAK,IAAI,EAAE;MACxBC,OAAO,EAAEN,KAAK,CAACM,OAAO,IAAI,EAAE;MAC5BC,OAAO,EAAEP,KAAK,CAACO,OAAO,IAAI;IAC5B,CAAC;EACH;;EAEA;EACA,IAAI,CAACC,KAAK,CAAC,CAAC;EAEZvB,MAAM,CAAC,WAAW,EAAE,IAAI,CAACwB,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BAAkB,GAAGC,IAAI,CAACC,SAAS,CACvC,IAAI,CAACC,KAAK,CAACC,UAAU,CAAC,IAAI,CAACtC,OAAO,IAAI,IAAI,CAACuC,WAAW,EAAEP,OAAO,CACjE,CAAC;QAED,IAAI,CAACQ,QAAQ,CACX,IAAI,EACH,GAAE/B,MAAM,CAACgC,IAAK,eAAcP,kBAAmB,IAAG,EACnDzB,MAAM,CAACxB,SAAS,IAAIR,SACtB,CAAC;MACH,CAAC,CAAC,OAAO+B,GAAG,EAAE;QACZ,IAAI,CAACgC,QAAQ,CAAChC,GAAY,CAAC;MAC7B;MAEA;IACF;IAEA,IAAI,CAACgC,QAAQ,CAAC,IAAI,EAAE/B,MAAM,CAACgC,IAAI,EAAEhC,MAAM,CAACxB,SAAS,IAAIR,SAAS,CAAC;EACjE,CAAC,EACA+B,GAAU,IAAK,IAAI,CAACgC,QAAQ,CAAChC,GAAG,CACnC,CAAC,CACAkC,KAAK,CAAElC,GAAU,IAAK,IAAI,CAACgC,QAAQ,CAAChC,GAAG,CAAC,CAAC;AAC9C,CAAC;AAED,eAAetC,cAAc"}
|
package/lib/index.js
CHANGED
|
@@ -46,6 +46,7 @@ const webpack5Loader = function webpack5LoaderPlugin(content, inputSourceMap) {
|
|
|
46
46
|
const {
|
|
47
47
|
sourceMap = undefined,
|
|
48
48
|
preprocessor = undefined,
|
|
49
|
+
prefixer = undefined,
|
|
49
50
|
extension = '.wyw-in-js.css',
|
|
50
51
|
cacheProvider,
|
|
51
52
|
...rest
|
|
@@ -73,9 +74,10 @@ const webpack5Loader = function webpack5LoaderPlugin(content, inputSourceMap) {
|
|
|
73
74
|
options: {
|
|
74
75
|
filename: this.resourcePath,
|
|
75
76
|
inputSourceMap: convertSourceMap(inputSourceMap, this.resourcePath),
|
|
76
|
-
|
|
77
|
+
pluginOptions: rest,
|
|
78
|
+
prefixer,
|
|
77
79
|
preprocessor,
|
|
78
|
-
|
|
80
|
+
root: process.cwd()
|
|
79
81
|
},
|
|
80
82
|
cache,
|
|
81
83
|
eventEmitter: _WYWinJSDebugPlugin.sharedState.emitter
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_path","_interopRequireDefault","require","_shared","_transform","_WYWinJSDebugPlugin","_cache","obj","__esModule","default","outputCssLoader","resolve","cache","TransformCacheCollection","webpack5Loader","webpack5LoaderPlugin","content","inputSourceMap","convertSourceMap","value","filename","_value$file","_value$mappings","_value$names","_value$sources","_value$version","undefined","file","mappings","names","sources","version","async","logger","resourcePath","sourceMap","preprocessor","extension","cacheProvider","rest","getOptions","outputFileName","replace","resolveModule","getResolve","dependencyType","asyncResolve","token","importer","context","path","isAbsolute","dirname","join","process","cwd","Promise","reject","err","result","addDependency","Error","transformServices","options","root","pluginOptions","eventEmitter","sharedState","emitter","transform","toString","then","_result$sourceMap2","cssText","_result$dependencies$","_result$dependencies","Buffer","from","cssSourceMapText","all","dependencies","map","dep","_cacheInstance$setDep","_result$sourceMap","cacheInstance","getCacheInstance","set","setDependencies","call","getDependencies","request","encodeURIComponent","stringifiedRequest","JSON","stringify","utils","contextify","rootContext","callback","code","catch","_default","exports"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * This file contains a Webpack loader for WYW-in-JS.\n * It uses the transform.ts function to generate class names from source code,\n * returns transformed code without template literals and attaches generated source maps\n */\n\nimport path from 'path';\n\nimport type { RawSourceMap } from 'source-map';\nimport type { RawLoaderDefinitionFunction } from 'webpack';\n\nimport { logger } from '@wyw-in-js/shared';\nimport type { Preprocessor, Result } from '@wyw-in-js/transform';\nimport { transform, TransformCacheCollection } from '@wyw-in-js/transform';\n\nimport { sharedState } from './WYWinJSDebugPlugin';\nimport type { ICache } from './cache';\nimport { getCacheInstance } from './cache';\n\nexport { WYWinJSDebugPlugin } from './WYWinJSDebugPlugin';\n\nconst outputCssLoader = require.resolve('./outputCssLoader');\n\nexport type LoaderOptions = {\n cacheProvider?: string | ICache;\n extension?: string;\n preprocessor?: Preprocessor;\n sourceMap?: boolean;\n};\ntype Loader = RawLoaderDefinitionFunction<LoaderOptions>;\n\nconst cache = new TransformCacheCollection();\n\nconst webpack5Loader: Loader = function webpack5LoaderPlugin(\n content,\n inputSourceMap\n) {\n function convertSourceMap(\n value: typeof inputSourceMap,\n filename: string\n ): RawSourceMap | undefined {\n if (typeof value === 'string' || !value) {\n return undefined;\n }\n\n return {\n ...value,\n file: value.file ?? filename,\n mappings: value.mappings ?? '',\n names: value.names ?? [],\n sources: value.sources ?? [],\n version: value.version ?? 3,\n };\n }\n\n // tell Webpack this loader is async\n this.async();\n\n logger('loader %s', this.resourcePath);\n\n const {\n sourceMap = undefined,\n preprocessor = undefined,\n extension = '.wyw-in-js.css',\n cacheProvider,\n ...rest\n } = this.getOptions() || {};\n\n const outputFileName = this.resourcePath.replace(/\\.[^.]+$/, extension);\n const resolveModule = this.getResolve({ dependencyType: 'esm' });\n\n const asyncResolve = (token: string, importer: string): Promise<string> => {\n const context = path.isAbsolute(importer)\n ? path.dirname(importer)\n : path.join(process.cwd(), path.dirname(importer));\n return new Promise((resolve, reject) => {\n resolveModule(context, token, (err, result) => {\n if (err) {\n reject(err);\n } else if (result) {\n this.addDependency(result);\n resolve(result);\n } else {\n reject(new Error(`Cannot resolve ${token}`));\n }\n });\n });\n };\n\n const transformServices = {\n options: {\n filename: this.resourcePath,\n inputSourceMap: convertSourceMap(inputSourceMap, this.resourcePath),\n root: process.cwd(),\n preprocessor,\n pluginOptions: rest,\n },\n cache,\n eventEmitter: sharedState.emitter,\n };\n\n transform(transformServices, content.toString(), asyncResolve)\n .then(\n async (result: Result) => {\n if (result.cssText) {\n let { cssText } = result;\n\n if (sourceMap) {\n cssText += `/*# sourceMappingURL=data:application/json;base64,${Buffer.from(\n result.cssSourceMapText || ''\n ).toString('base64')}*/`;\n }\n\n await Promise.all(\n result.dependencies?.map((dep) =>\n asyncResolve(dep, this.resourcePath)\n ) ?? []\n );\n\n try {\n const cacheInstance = await getCacheInstance(cacheProvider);\n\n await cacheInstance.set(this.resourcePath, cssText);\n\n await cacheInstance.setDependencies?.(\n this.resourcePath,\n this.getDependencies()\n );\n\n const request = `${outputFileName}!=!${outputCssLoader}?cacheProvider=${encodeURIComponent(\n typeof cacheProvider === 'string' ? cacheProvider : ''\n )}!${this.resourcePath}`;\n const stringifiedRequest = JSON.stringify(\n this.utils.contextify(this.context || this.rootContext, request)\n );\n\n this.callback(\n null,\n `${result.code}\\n\\nrequire(${stringifiedRequest});`,\n result.sourceMap ?? undefined\n );\n } catch (err) {\n this.callback(err as Error);\n }\n\n return;\n }\n\n this.callback(null, result.code, result.sourceMap ?? undefined);\n },\n (err: Error) => this.callback(err)\n )\n .catch((err: Error) => this.callback(err));\n};\n\nexport default webpack5Loader;\n"],"mappings":";;;;;;;;;;;;AAMA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,UAAA,GAAAF,OAAA;AAEA,IAAAG,mBAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AAA2C,SAAAD,uBAAAM,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAjB3C;AACA;AACA;AACA;AACA;;AAiBA,MAAMG,eAAe,GAAGR,OAAO,CAACS,OAAO,CAAC,mBAAmB,CAAC;AAU5D,MAAMC,KAAK,GAAG,IAAIC,mCAAwB,CAAC,CAAC;AAE5C,MAAMC,cAAsB,GAAG,SAASC,oBAAoBA,CAC1DC,OAAO,EACPC,cAAc,EACd;EACA,SAASC,gBAAgBA,CACvBC,KAA4B,EAC5BC,QAAgB,EACU;IAAA,IAAAC,WAAA,EAAAC,eAAA,EAAAC,YAAA,EAAAC,cAAA,EAAAC,cAAA;IAC1B,IAAI,OAAON,KAAK,KAAK,QAAQ,IAAI,CAACA,KAAK,EAAE;MACvC,OAAOO,SAAS;IAClB;IAEA,OAAO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IAAI,CAACyC,QAAQ,CAAC,IAAI,EAAExC,MAAM,CAACyC,IAAI,GAAA5B,kBAAA,GAAEb,MAAM,CAACxB,SAAS,cAAAqC,kBAAA,cAAAA,kBAAA,GAAI9C,SAAS,CAAC;EACjE,CAAC,EACAgC,GAAU,IAAK,IAAI,CAACyC,QAAQ,CAACzC,GAAG,CACnC,CAAC,CACA2C,KAAK,CAAE3C,GAAU,IAAK,IAAI,CAACyC,QAAQ,CAACzC,GAAG,CAAC,CAAC;AAC9C,CAAC;AAAC,IAAA4C,QAAA,GAAAC,OAAA,CAAA9F,OAAA,GAEaK,cAAc"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_path","_interopRequireDefault","require","_shared","_transform","_WYWinJSDebugPlugin","_cache","obj","__esModule","default","outputCssLoader","resolve","cache","TransformCacheCollection","webpack5Loader","webpack5LoaderPlugin","content","inputSourceMap","convertSourceMap","value","filename","_value$file","_value$mappings","_value$names","_value$sources","_value$version","undefined","file","mappings","names","sources","version","async","logger","resourcePath","sourceMap","preprocessor","prefixer","extension","cacheProvider","rest","getOptions","outputFileName","replace","resolveModule","getResolve","dependencyType","asyncResolve","token","importer","context","path","isAbsolute","dirname","join","process","cwd","Promise","reject","err","result","addDependency","Error","transformServices","options","pluginOptions","root","eventEmitter","sharedState","emitter","transform","toString","then","_result$sourceMap2","cssText","_result$dependencies$","_result$dependencies","Buffer","from","cssSourceMapText","all","dependencies","map","dep","_cacheInstance$setDep","_result$sourceMap","cacheInstance","getCacheInstance","set","setDependencies","call","getDependencies","request","encodeURIComponent","stringifiedRequest","JSON","stringify","utils","contextify","rootContext","callback","code","catch","_default","exports"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * This file contains a Webpack loader for WYW-in-JS.\n * It uses the transform.ts function to generate class names from source code,\n * returns transformed code without template literals and attaches generated source maps\n */\n\nimport path from 'path';\n\nimport type { RawSourceMap } from 'source-map';\nimport type { RawLoaderDefinitionFunction } from 'webpack';\n\nimport { logger } from '@wyw-in-js/shared';\nimport type { Preprocessor, Result } from '@wyw-in-js/transform';\nimport { transform, TransformCacheCollection } from '@wyw-in-js/transform';\n\nimport { sharedState } from './WYWinJSDebugPlugin';\nimport type { ICache } from './cache';\nimport { getCacheInstance } from './cache';\n\nexport { WYWinJSDebugPlugin } from './WYWinJSDebugPlugin';\n\nconst outputCssLoader = require.resolve('./outputCssLoader');\n\nexport type LoaderOptions = {\n cacheProvider?: string | ICache;\n extension?: string;\n prefixer?: boolean;\n preprocessor?: Preprocessor;\n sourceMap?: boolean;\n};\ntype Loader = RawLoaderDefinitionFunction<LoaderOptions>;\n\nconst cache = new TransformCacheCollection();\n\nconst webpack5Loader: Loader = function webpack5LoaderPlugin(\n content,\n inputSourceMap\n) {\n function convertSourceMap(\n value: typeof inputSourceMap,\n filename: string\n ): RawSourceMap | undefined {\n if (typeof value === 'string' || !value) {\n return undefined;\n }\n\n return {\n ...value,\n file: value.file ?? filename,\n mappings: value.mappings ?? '',\n names: value.names ?? [],\n sources: value.sources ?? [],\n version: value.version ?? 3,\n };\n }\n\n // tell Webpack this loader is async\n this.async();\n\n logger('loader %s', this.resourcePath);\n\n const {\n sourceMap = undefined,\n preprocessor = undefined,\n prefixer = undefined,\n extension = '.wyw-in-js.css',\n cacheProvider,\n ...rest\n } = this.getOptions() || {};\n\n const outputFileName = this.resourcePath.replace(/\\.[^.]+$/, extension);\n const resolveModule = this.getResolve({ dependencyType: 'esm' });\n\n const asyncResolve = (token: string, importer: string): Promise<string> => {\n const context = path.isAbsolute(importer)\n ? path.dirname(importer)\n : path.join(process.cwd(), path.dirname(importer));\n return new Promise((resolve, reject) => {\n resolveModule(context, token, (err, result) => {\n if (err) {\n reject(err);\n } else if (result) {\n this.addDependency(result);\n resolve(result);\n } else {\n reject(new Error(`Cannot resolve ${token}`));\n }\n });\n });\n };\n\n const transformServices = {\n options: {\n filename: this.resourcePath,\n inputSourceMap: convertSourceMap(inputSourceMap, this.resourcePath),\n pluginOptions: rest,\n prefixer,\n preprocessor,\n root: process.cwd(),\n },\n cache,\n eventEmitter: sharedState.emitter,\n };\n\n transform(transformServices, content.toString(), asyncResolve)\n .then(\n async (result: Result) => {\n if (result.cssText) {\n let { cssText } = result;\n\n if (sourceMap) {\n cssText += `/*# sourceMappingURL=data:application/json;base64,${Buffer.from(\n result.cssSourceMapText || ''\n ).toString('base64')}*/`;\n }\n\n await Promise.all(\n result.dependencies?.map((dep) =>\n asyncResolve(dep, this.resourcePath)\n ) ?? []\n );\n\n try {\n const cacheInstance = await getCacheInstance(cacheProvider);\n\n await cacheInstance.set(this.resourcePath, cssText);\n\n await cacheInstance.setDependencies?.(\n this.resourcePath,\n this.getDependencies()\n );\n\n const request = `${outputFileName}!=!${outputCssLoader}?cacheProvider=${encodeURIComponent(\n typeof cacheProvider === 'string' ? cacheProvider : ''\n )}!${this.resourcePath}`;\n const stringifiedRequest = JSON.stringify(\n this.utils.contextify(this.context || this.rootContext, request)\n );\n\n this.callback(\n null,\n `${result.code}\\n\\nrequire(${stringifiedRequest});`,\n result.sourceMap ?? undefined\n );\n } catch (err) {\n this.callback(err as Error);\n }\n\n return;\n }\n\n this.callback(null, result.code, result.sourceMap ?? undefined);\n },\n (err: Error) => this.callback(err)\n )\n .catch((err: Error) => this.callback(err));\n};\n\nexport default webpack5Loader;\n"],"mappings":";;;;;;;;;;;;AAMA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,UAAA,GAAAF,OAAA;AAEA,IAAAG,mBAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AAA2C,SAAAD,uBAAAM,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAjB3C;AACA;AACA;AACA;AACA;;AAiBA,MAAMG,eAAe,GAAGR,OAAO,CAACS,OAAO,CAAC,mBAAmB,CAAC;AAW5D,MAAMC,KAAK,GAAG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U,CAAC,IAAI,CAAChD,OAAO,IAAI,IAAI,CAACiD,WAAW,EAAEP,OAAO,CACjE,CAAC;QAED,IAAI,CAACQ,QAAQ,CACX,IAAI,EACH,GAAExC,MAAM,CAACyC,IAAK,eAAcP,kBAAmB,IAAG,GAAAT,iBAAA,GACnDzB,MAAM,CAACzB,SAAS,cAAAkD,iBAAA,cAAAA,iBAAA,GAAI3D,SACtB,CAAC;MACH,CAAC,CAAC,OAAOiC,GAAG,EAAE;QACZ,IAAI,CAACyC,QAAQ,CAACzC,GAAY,CAAC;MAC7B;MAEA;IACF;IAEA,IAAI,CAACyC,QAAQ,CAAC,IAAI,EAAExC,MAAM,CAACyC,IAAI,GAAA5B,kBAAA,GAAEb,MAAM,CAACzB,SAAS,cAAAsC,kBAAA,cAAAA,kBAAA,GAAI/C,SAAS,CAAC;EACjE,CAAC,EACAiC,GAAU,IAAK,IAAI,CAACyC,QAAQ,CAACzC,GAAG,CACnC,CAAC,CACA2C,KAAK,CAAE3C,GAAU,IAAK,IAAI,CAACyC,QAAQ,CAACzC,GAAG,CAAC,CAAC;AAC9C,CAAC;AAAC,IAAA4C,QAAA,GAAAC,OAAA,CAAA/F,OAAA,GAEaK,cAAc"}
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wyw-in-js/webpack-loader",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@wyw-in-js/shared": "0.
|
|
6
|
-
"@wyw-in-js/transform": "0.
|
|
5
|
+
"@wyw-in-js/shared": "0.8.0",
|
|
6
|
+
"@wyw-in-js/transform": "0.8.0"
|
|
7
7
|
},
|
|
8
8
|
"devDependencies": {
|
|
9
9
|
"@types/node": "^16.18.55",
|
|
10
10
|
"source-map": "^0.7.4",
|
|
11
11
|
"webpack": "^5.76.0",
|
|
12
|
-
"@wyw-in-js/babel-config": "0.
|
|
13
|
-
"@wyw-in-js/eslint-config": "0.
|
|
14
|
-
"@wyw-in-js/jest-preset": "0.
|
|
15
|
-
"@wyw-in-js/ts-config": "0.
|
|
12
|
+
"@wyw-in-js/babel-config": "0.8.0",
|
|
13
|
+
"@wyw-in-js/eslint-config": "0.8.0",
|
|
14
|
+
"@wyw-in-js/jest-preset": "0.8.0",
|
|
15
|
+
"@wyw-in-js/ts-config": "0.8.0"
|
|
16
16
|
},
|
|
17
17
|
"engines": {
|
|
18
18
|
"node": ">=16.0.0"
|
package/types/index.d.ts
CHANGED
package/types/index.js
CHANGED
|
@@ -35,7 +35,7 @@ const webpack5Loader = function webpack5LoaderPlugin(content, inputSourceMap) {
|
|
|
35
35
|
// tell Webpack this loader is async
|
|
36
36
|
this.async();
|
|
37
37
|
(0, shared_1.logger)('loader %s', this.resourcePath);
|
|
38
|
-
const { sourceMap = undefined, preprocessor = undefined, extension = '.wyw-in-js.css', cacheProvider, ...rest } = this.getOptions() || {};
|
|
38
|
+
const { sourceMap = undefined, preprocessor = undefined, prefixer = undefined, extension = '.wyw-in-js.css', cacheProvider, ...rest } = this.getOptions() || {};
|
|
39
39
|
const outputFileName = this.resourcePath.replace(/\.[^.]+$/, extension);
|
|
40
40
|
const resolveModule = this.getResolve({ dependencyType: 'esm' });
|
|
41
41
|
const asyncResolve = (token, importer) => {
|
|
@@ -61,9 +61,10 @@ const webpack5Loader = function webpack5LoaderPlugin(content, inputSourceMap) {
|
|
|
61
61
|
options: {
|
|
62
62
|
filename: this.resourcePath,
|
|
63
63
|
inputSourceMap: convertSourceMap(inputSourceMap, this.resourcePath),
|
|
64
|
-
root: process.cwd(),
|
|
65
|
-
preprocessor,
|
|
66
64
|
pluginOptions: rest,
|
|
65
|
+
prefixer,
|
|
66
|
+
preprocessor,
|
|
67
|
+
root: process.cwd(),
|
|
67
68
|
},
|
|
68
69
|
cache,
|
|
69
70
|
eventEmitter: WYWinJSDebugPlugin_1.sharedState.emitter,
|