@@ -22,7 +22,6 @@ import { patchContext } from './lib/context.js';
2222 * @param {import('./index.js').Options } _options
2323 */
2424export const setup = ( build , _options ) => {
25- build . initialOptions . metafile = true ;
2625 const options = _options || { } ;
2726 validateOptions ( options ) ;
2827
@@ -41,6 +40,25 @@ export const setup = (build, _options) => {
4140 const forceInlineImages = ! ! options . forceInlineImages ;
4241 const emitDts = options . emitDeclarationFile ;
4342
43+ const warnMetafile = ( ) => {
44+ if ( patchedBuild . initialOptions . metafile ) {
45+ return ;
46+ }
47+ const warnings = patchedBuild . esbuild . formatMessagesSync (
48+ [
49+ {
50+ text : '`metafile` is not enabled, it may not work properly, please consider to set `metafile` to true is your esbuild configuration.' ,
51+ pluginName : pluginName
52+ }
53+ ] ,
54+ {
55+ kind : 'warning' ,
56+ color : true
57+ }
58+ ) ;
59+ console . log ( warnings . join ( '\n' ) ) ;
60+ }
61+
4462 patchedBuild . onLoad ( { filter : / .+ / , namespace : pluginCssNamespace } , ( args ) => {
4563 const { path } = args ;
4664 log ( `[${ pluginCssNamespace } ] on load:` , args ) ;
@@ -245,6 +263,7 @@ export const setup = (build, _options) => {
245263 /** @type {[string, string][] } */
246264 const moduleJsFiles = [ ] ;
247265
266+ warnMetafile ( ) ;
248267 Object . entries ( r . metafile ?. outputs ?? { } ) . forEach ( ( [ js , meta ] ) => {
249268 if ( meta . entryPoint && modulesCssRegExp . test ( meta . entryPoint ) ) {
250269 moduleJsFiles . push ( [ meta . entryPoint , js ] ) ;
@@ -300,6 +319,7 @@ export const setup = (build, _options) => {
300319
301320 /** @type {[string, string][] } */
302321 const filesToBuild = [ ] ;
322+ warnMetafile ( ) ;
303323 Object . entries ( r . metafile ?. outputs ?? { } ) . forEach ( ( [ outfile , meta ] ) => {
304324 if ( meta . cssBundle ) {
305325 filesToBuild . push ( [ outfile , meta . cssBundle ] ) ;
0 commit comments