extension-develop 3.1.0-next.5 → 3.1.0-next.7
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/{329.js → 547.js} +104 -754
- package/dist/module.js +128099 -79
- package/package.json +1 -1
- package/dist/814.js +0 -127125
- /package/dist/{814.js.LICENSE.txt → module.js.LICENSE.txt} +0 -0
package/dist/{329.js → 547.js}
RENAMED
|
@@ -3,7 +3,7 @@ const __rslib_import_meta_url__ = /*#__PURE__*/ function() {
|
|
|
3
3
|
return "u" < typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
4
4
|
}();
|
|
5
5
|
exports.ids = [
|
|
6
|
-
"
|
|
6
|
+
"547"
|
|
7
7
|
];
|
|
8
8
|
exports.modules = {
|
|
9
9
|
"./webpack/webpack-config.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
@@ -461,196 +461,10 @@ exports.modules = {
|
|
|
461
461
|
}
|
|
462
462
|
}
|
|
463
463
|
plugin_compilation_define_property(CompilationPlugin, "name", 'plugin-compilation');
|
|
464
|
-
|
|
465
|
-
const list = integrations.length > 0 ? integrations.map((n)=>external_pintor_default().yellow(n)).join(', ') : external_pintor_default().gray('none');
|
|
466
|
-
return `${external_pintor_default().gray('►►►')} CSS: Integrations enabled (${external_pintor_default().gray(String(integrations.length))}) ${list}`;
|
|
467
|
-
}
|
|
468
|
-
function cssConfigsDetected(postcssConfig, stylelintConfig, tailwindConfig, browserslistSource) {
|
|
469
|
-
const fmt = (v)=>v ? external_pintor_default().underline(v) : external_pintor_default().gray('none');
|
|
470
|
-
return `${external_pintor_default().gray('►►►')} CSS: Configs\n${external_pintor_default().gray('POSTCSS')} ${fmt(postcssConfig)}\n${external_pintor_default().gray('STYLELINT')} ${fmt(stylelintConfig)}\n${external_pintor_default().gray('TAILWIND')} ${fmt(tailwindConfig)}\n${external_pintor_default().gray('BROWSERSLIST')} ${fmt(browserslistSource)}`;
|
|
471
|
-
}
|
|
472
|
-
function isUsingIntegration(name) {
|
|
473
|
-
return `${external_pintor_default().gray('►►►')} Using ${external_pintor_default().brightBlue(name)}...`;
|
|
474
|
-
}
|
|
475
|
-
function youAreAllSet(name) {
|
|
476
|
-
return `${external_pintor_default().green('►►►')} ${name} installation completed. Run again to proceed.`;
|
|
477
|
-
}
|
|
478
|
-
function missingSassDependency() {
|
|
479
|
-
const prefix = external_pintor_default().red('►►►');
|
|
480
|
-
return [
|
|
481
|
-
`${prefix} SASS support requires the ${external_pintor_default().brightBlue('"sass"')} package to be installed in your project.`,
|
|
482
|
-
'',
|
|
483
|
-
"Add it to your devDependencies, for example:",
|
|
484
|
-
` ${external_pintor_default().gray('npm install --save-dev sass')}`,
|
|
485
|
-
` ${external_pintor_default().gray('pnpm add -D sass')}`,
|
|
486
|
-
'',
|
|
487
|
-
'Sample package.json:',
|
|
488
|
-
' {',
|
|
489
|
-
' "devDependencies": {',
|
|
490
|
-
` "sass": ${external_pintor_default().yellow('"<version>"')}`,
|
|
491
|
-
' }',
|
|
492
|
-
' }'
|
|
493
|
-
].join('\n');
|
|
494
|
-
}
|
|
464
|
+
var css_lib_messages = __webpack_require__("./webpack/plugin-css/css-lib/messages.ts");
|
|
495
465
|
var css_lib_integrations = __webpack_require__("./webpack/plugin-css/css-lib/integrations.ts");
|
|
496
|
-
var
|
|
497
|
-
|
|
498
|
-
function isUsingSass(projectPath) {
|
|
499
|
-
if ((0, css_lib_integrations.w)(projectPath, 'sass')) {
|
|
500
|
-
if (!userMessageDelivered) {
|
|
501
|
-
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(`${external_pintor_default().brightMagenta('►►► Author says')} ${isUsingIntegration('SASS')}`);
|
|
502
|
-
userMessageDelivered = true;
|
|
503
|
-
}
|
|
504
|
-
return true;
|
|
505
|
-
}
|
|
506
|
-
return false;
|
|
507
|
-
}
|
|
508
|
-
function resolveSassImplementation(projectPath) {
|
|
509
|
-
const bases = [
|
|
510
|
-
projectPath,
|
|
511
|
-
process.cwd()
|
|
512
|
-
];
|
|
513
|
-
for (const base of bases)try {
|
|
514
|
-
const req = (0, external_module_.createRequire)(external_path_.join(base, 'package.json'));
|
|
515
|
-
let mod = req('sass');
|
|
516
|
-
if (mod && 'object' == typeof mod && 'default' in mod) mod = mod.default;
|
|
517
|
-
return mod;
|
|
518
|
-
} catch {}
|
|
519
|
-
try {
|
|
520
|
-
let mod = __webpack_require__("../../node_modules/.pnpm/sass@1.97.2/node_modules/sass/sass.node.js");
|
|
521
|
-
if (mod && 'object' == typeof mod && 'default' in mod) mod = mod.default;
|
|
522
|
-
return mod;
|
|
523
|
-
} catch {
|
|
524
|
-
return;
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
function createSassLoaderOptions(projectPath, mode) {
|
|
528
|
-
const implementation = resolveSassImplementation(projectPath);
|
|
529
|
-
const usingSass = isUsingSass(projectPath);
|
|
530
|
-
if (usingSass && !implementation) throw new Error(missingSassDependency());
|
|
531
|
-
const base = {
|
|
532
|
-
sourceMap: 'development' === mode,
|
|
533
|
-
sassOptions: {
|
|
534
|
-
outputStyle: 'expanded'
|
|
535
|
-
}
|
|
536
|
-
};
|
|
537
|
-
if (implementation) base.implementation = implementation;
|
|
538
|
-
return base;
|
|
539
|
-
}
|
|
540
|
-
async function maybeUseSass(projectPath) {
|
|
541
|
-
if (!isUsingSass(projectPath)) return [];
|
|
542
|
-
try {
|
|
543
|
-
require.resolve('sass-loader');
|
|
544
|
-
} catch (e) {
|
|
545
|
-
const postCssDependencies = [
|
|
546
|
-
'postcss-loader',
|
|
547
|
-
'postcss-scss',
|
|
548
|
-
'postcss-preset-env'
|
|
549
|
-
];
|
|
550
|
-
await (0, css_lib_integrations.t)('PostCSS', postCssDependencies);
|
|
551
|
-
const sassDependencies = [
|
|
552
|
-
'sass-loader'
|
|
553
|
-
];
|
|
554
|
-
await (0, css_lib_integrations.t)('SASS', sassDependencies);
|
|
555
|
-
console.log(youAreAllSet('SASS'));
|
|
556
|
-
process.exit(0);
|
|
557
|
-
}
|
|
558
|
-
return [
|
|
559
|
-
{
|
|
560
|
-
test: /\.(sass|scss)$/,
|
|
561
|
-
exclude: /\.module\.(sass|scss)$/,
|
|
562
|
-
use: [
|
|
563
|
-
{
|
|
564
|
-
loader: require.resolve('sass-loader'),
|
|
565
|
-
options: createSassLoaderOptions(projectPath, 'development')
|
|
566
|
-
}
|
|
567
|
-
]
|
|
568
|
-
},
|
|
569
|
-
{
|
|
570
|
-
test: /\.module\.(sass|scss)$/,
|
|
571
|
-
use: [
|
|
572
|
-
{
|
|
573
|
-
loader: require.resolve('sass-loader'),
|
|
574
|
-
options: createSassLoaderOptions(projectPath, 'development')
|
|
575
|
-
}
|
|
576
|
-
]
|
|
577
|
-
}
|
|
578
|
-
];
|
|
579
|
-
}
|
|
580
|
-
function is_content_script_parseJsonSafe(text) {
|
|
581
|
-
const s = text && 0xfeff === text.charCodeAt(0) ? text.slice(1) : text;
|
|
582
|
-
return JSON.parse(s || '{}');
|
|
583
|
-
}
|
|
584
|
-
function isContentScriptEntry(absolutePath, manifestPath) {
|
|
585
|
-
if (!absolutePath || !manifestPath) return false;
|
|
586
|
-
if (!external_fs_.existsSync(manifestPath)) return false;
|
|
587
|
-
const manifest = is_content_script_parseJsonSafe(external_fs_.readFileSync(manifestPath, 'utf8'));
|
|
588
|
-
for (const content of manifest.content_scripts || [])if (content.js?.length) for (const js of content.js){
|
|
589
|
-
const contentPath = external_path_.resolve(external_path_.dirname(manifestPath), js);
|
|
590
|
-
if (contentPath === absolutePath) return true;
|
|
591
|
-
}
|
|
592
|
-
return false;
|
|
593
|
-
}
|
|
594
|
-
let less_userMessageDelivered = false;
|
|
595
|
-
function isUsingLess(projectPath) {
|
|
596
|
-
if ((0, css_lib_integrations.w)(projectPath, 'less')) {
|
|
597
|
-
if (!less_userMessageDelivered) {
|
|
598
|
-
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(`${external_pintor_default().brightMagenta('►►► Author says')} ${isUsingIntegration('LESS')}`);
|
|
599
|
-
less_userMessageDelivered = true;
|
|
600
|
-
}
|
|
601
|
-
return true;
|
|
602
|
-
}
|
|
603
|
-
return false;
|
|
604
|
-
}
|
|
605
|
-
async function maybeUseLess(projectPath, manifestPath) {
|
|
606
|
-
const resolvedManifestPath = manifestPath || external_path_.join(projectPath, 'manifest.json');
|
|
607
|
-
if (!isUsingLess(projectPath)) return [];
|
|
608
|
-
try {
|
|
609
|
-
require.resolve('less-loader');
|
|
610
|
-
} catch (e) {
|
|
611
|
-
const lessDependencies = [
|
|
612
|
-
'less',
|
|
613
|
-
'less-loader'
|
|
614
|
-
];
|
|
615
|
-
await (0, css_lib_integrations.t)('LESS', lessDependencies);
|
|
616
|
-
console.log(youAreAllSet('LESS'));
|
|
617
|
-
process.exit(0);
|
|
618
|
-
}
|
|
619
|
-
return [
|
|
620
|
-
{
|
|
621
|
-
test: /\.less$/,
|
|
622
|
-
exclude: /\.module\.less$/,
|
|
623
|
-
use: [
|
|
624
|
-
{
|
|
625
|
-
loader: require.resolve('less-loader'),
|
|
626
|
-
options: {
|
|
627
|
-
sourceMap: true
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
]
|
|
631
|
-
},
|
|
632
|
-
{
|
|
633
|
-
test: /\.module\.less$/,
|
|
634
|
-
use: [
|
|
635
|
-
{
|
|
636
|
-
loader: require.resolve('less-loader'),
|
|
637
|
-
options: {
|
|
638
|
-
sourceMap: true
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
]
|
|
642
|
-
},
|
|
643
|
-
{
|
|
644
|
-
test: /\.less$/,
|
|
645
|
-
exclude: /\.module\.less$/,
|
|
646
|
-
type: 'asset/resource',
|
|
647
|
-
generator: {
|
|
648
|
-
filename: "content_scripts/[name].[contenthash:8].css"
|
|
649
|
-
},
|
|
650
|
-
issuer: (issuer)=>isContentScriptEntry(issuer, resolvedManifestPath)
|
|
651
|
-
}
|
|
652
|
-
];
|
|
653
|
-
}
|
|
466
|
+
var sass = __webpack_require__("./webpack/plugin-css/css-tools/sass.ts");
|
|
467
|
+
var less = __webpack_require__("./webpack/plugin-css/css-tools/less.ts");
|
|
654
468
|
function getStylelintConfigFile(projectPath) {
|
|
655
469
|
const stylelintConfigJs = external_path_.join(projectPath, 'stylelint.config.js');
|
|
656
470
|
const stylelintConfigDotJs = external_path_.join(projectPath, '.stylelintrc.js');
|
|
@@ -673,16 +487,16 @@ exports.modules = {
|
|
|
673
487
|
if (external_fs_.existsSync(stylelintConfigYml)) return stylelintConfigYml;
|
|
674
488
|
if (external_fs_.existsSync(stylelintConfigDotYml)) return stylelintConfigDotYml;
|
|
675
489
|
}
|
|
676
|
-
let
|
|
490
|
+
let userMessageDelivered = false;
|
|
677
491
|
function stylelint_isUsingStylelint(projectPath) {
|
|
678
492
|
const packageJsonPath = external_path_.join(projectPath, 'package.json');
|
|
679
493
|
if (!external_fs_.existsSync(packageJsonPath)) return false;
|
|
680
494
|
const configFile = getStylelintConfigFile(projectPath);
|
|
681
495
|
const isUsingStylelint = !!configFile;
|
|
682
496
|
if (isUsingStylelint) {
|
|
683
|
-
if (!
|
|
684
|
-
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(`${external_pintor_default().brightMagenta('►►► Author says')} ${
|
|
685
|
-
|
|
497
|
+
if (!userMessageDelivered) {
|
|
498
|
+
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(`${external_pintor_default().brightMagenta('►►► Author says')} ${css_lib_messages.zA('Stylelint')}`);
|
|
499
|
+
userMessageDelivered = true;
|
|
686
500
|
}
|
|
687
501
|
}
|
|
688
502
|
return isUsingStylelint;
|
|
@@ -691,154 +505,12 @@ exports.modules = {
|
|
|
691
505
|
stylelint_isUsingStylelint(projectPath);
|
|
692
506
|
return [];
|
|
693
507
|
}
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
const isUsingTailwind = (0, css_lib_integrations.w)(projectPath, 'tailwindcss') || (0, css_lib_integrations.w)(projectPath, '@tailwindcss/postcss');
|
|
697
|
-
if (isUsingTailwind) {
|
|
698
|
-
if (!tailwind_userMessageDelivered) {
|
|
699
|
-
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(`${external_pintor_default().brightMagenta('►►► Author says')} ${isUsingIntegration('Tailwind')}`);
|
|
700
|
-
tailwind_userMessageDelivered = true;
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
return isUsingTailwind;
|
|
704
|
-
}
|
|
705
|
-
function getTailwindConfigFile(projectPath) {
|
|
706
|
-
const configFileMjs = external_path_.join(projectPath, 'tailwind.config.mjs');
|
|
707
|
-
const configFileCjs = external_path_.join(projectPath, 'tailwind.config.cjs');
|
|
708
|
-
const configFileJs = external_path_.join(projectPath, 'tailwind.config.js');
|
|
709
|
-
if (external_fs_.existsSync(configFileMjs)) return configFileMjs;
|
|
710
|
-
if (external_fs_.existsSync(configFileCjs)) return configFileCjs;
|
|
711
|
-
if (external_fs_.existsSync(configFileJs)) return configFileJs;
|
|
712
|
-
}
|
|
713
|
-
let postcss_userMessageDelivered = false;
|
|
714
|
-
const postCssConfigFiles = [
|
|
715
|
-
'.postcssrc',
|
|
716
|
-
'.postcssrc.json',
|
|
717
|
-
'.postcssrc.yaml',
|
|
718
|
-
'.postcssrc.yml',
|
|
719
|
-
'postcss.config.mjs',
|
|
720
|
-
'.postcssrc.js',
|
|
721
|
-
'.postcssrc.cjs',
|
|
722
|
-
'postcss.config.js',
|
|
723
|
-
'postcss.config.cjs'
|
|
724
|
-
];
|
|
725
|
-
function findPostCssConfig(projectPath) {
|
|
726
|
-
for (const configFile of postCssConfigFiles){
|
|
727
|
-
const configPath = external_path_.join(projectPath, configFile);
|
|
728
|
-
if (external_fs_.existsSync(configPath)) return configPath;
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
function isUsingPostCss(projectPath) {
|
|
732
|
-
if ((0, css_lib_integrations.w)(projectPath, 'postcss')) {
|
|
733
|
-
if (!postcss_userMessageDelivered) {
|
|
734
|
-
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(`${external_pintor_default().brightMagenta('►►► Author says')} ${isUsingIntegration('PostCSS')}`);
|
|
735
|
-
postcss_userMessageDelivered = true;
|
|
736
|
-
}
|
|
737
|
-
return true;
|
|
738
|
-
}
|
|
739
|
-
if (findPostCssConfig(projectPath)) {
|
|
740
|
-
if (!postcss_userMessageDelivered) {
|
|
741
|
-
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(`${external_pintor_default().brightMagenta('►►► Author says')} ${isUsingIntegration('PostCSS')}`);
|
|
742
|
-
postcss_userMessageDelivered = true;
|
|
743
|
-
}
|
|
744
|
-
return true;
|
|
745
|
-
}
|
|
746
|
-
if (tailwind_isUsingTailwind(projectPath)) {
|
|
747
|
-
if (!postcss_userMessageDelivered) {
|
|
748
|
-
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(`${external_pintor_default().brightMagenta('►►► Author says')} ${isUsingIntegration('PostCSS')}`);
|
|
749
|
-
postcss_userMessageDelivered = true;
|
|
750
|
-
}
|
|
751
|
-
return true;
|
|
752
|
-
}
|
|
753
|
-
return false;
|
|
754
|
-
}
|
|
755
|
-
async function maybeUsePostCss(projectPath, opts) {
|
|
756
|
-
const userPostCssConfig = findPostCssConfig(projectPath);
|
|
757
|
-
function getPackageJsonConfig(p) {
|
|
758
|
-
try {
|
|
759
|
-
const raw = external_fs_.readFileSync(external_path_.join(p, 'package.json'), 'utf8');
|
|
760
|
-
const pkg = JSON.parse(raw || '{}');
|
|
761
|
-
return {
|
|
762
|
-
hasPostCss: !!pkg?.postcss,
|
|
763
|
-
config: pkg?.postcss
|
|
764
|
-
};
|
|
765
|
-
} catch {
|
|
766
|
-
return {
|
|
767
|
-
hasPostCss: false
|
|
768
|
-
};
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
const { hasPostCss: pkgHasPostCss, config: pkgPostCssConfig } = getPackageJsonConfig(projectPath);
|
|
772
|
-
const tailwindPresent = tailwind_isUsingTailwind(projectPath);
|
|
773
|
-
if (!userPostCssConfig && !pkgHasPostCss && !tailwindPresent) return {};
|
|
774
|
-
try {
|
|
775
|
-
require.resolve('postcss-loader');
|
|
776
|
-
} catch (e) {
|
|
777
|
-
if (!isUsingSass(projectPath) && !isUsingLess(projectPath)) {
|
|
778
|
-
const postCssDependencies = [
|
|
779
|
-
'postcss',
|
|
780
|
-
'postcss-loader'
|
|
781
|
-
];
|
|
782
|
-
await (0, css_lib_integrations.t)('PostCSS', postCssDependencies);
|
|
783
|
-
}
|
|
784
|
-
console.log(youAreAllSet('PostCSS'));
|
|
785
|
-
process.exit(0);
|
|
786
|
-
}
|
|
787
|
-
let pluginsFromOptions;
|
|
788
|
-
if (tailwindPresent) try {
|
|
789
|
-
const bases = [
|
|
790
|
-
projectPath,
|
|
791
|
-
process.cwd()
|
|
792
|
-
];
|
|
793
|
-
let tailwindMod;
|
|
794
|
-
for (const base of bases)try {
|
|
795
|
-
const req = (0, external_module_.createRequire)(external_path_.join(base, 'package.json'));
|
|
796
|
-
tailwindMod = req('@tailwindcss/postcss');
|
|
797
|
-
break;
|
|
798
|
-
} catch (e) {}
|
|
799
|
-
if (tailwindMod) {
|
|
800
|
-
if (tailwindMod && 'object' == typeof tailwindMod && 'default' in tailwindMod) tailwindMod = tailwindMod.default;
|
|
801
|
-
if ('function' == typeof tailwindMod) {
|
|
802
|
-
const instance = tailwindMod();
|
|
803
|
-
pluginsFromOptions = [
|
|
804
|
-
{
|
|
805
|
-
'@tailwindcss/postcss': false
|
|
806
|
-
},
|
|
807
|
-
instance
|
|
808
|
-
];
|
|
809
|
-
} else if (tailwindMod && 'object' == typeof tailwindMod && 'postcssPlugin' in tailwindMod) pluginsFromOptions = [
|
|
810
|
-
{
|
|
811
|
-
'@tailwindcss/postcss': false
|
|
812
|
-
},
|
|
813
|
-
tailwindMod
|
|
814
|
-
];
|
|
815
|
-
}
|
|
816
|
-
} catch {}
|
|
817
|
-
const postcssOptions = {
|
|
818
|
-
ident: 'postcss',
|
|
819
|
-
cwd: projectPath,
|
|
820
|
-
config: projectPath
|
|
821
|
-
};
|
|
822
|
-
if (pluginsFromOptions) postcssOptions.plugins = pluginsFromOptions;
|
|
823
|
-
if ('true' === process.env.EXTENSION_AUTHOR_MODE) try {
|
|
824
|
-
console.log(`${external_pintor_default().brightMagenta('►►► Author says')} [extension.js:postcss] projectPath=%s userPostCssConfig=%s pkgHasPostCss=%s tailwindPresent=%s`, projectPath, userPostCssConfig || 'none', pkgHasPostCss, tailwindPresent);
|
|
825
|
-
const resolvedPluginsCount = Array.isArray(postcssOptions.plugins) ? postcssOptions.plugins.length : 0;
|
|
826
|
-
console.log(`${external_pintor_default().brightMagenta('►►► Author says')} [extension.js:postcss] resolvedPlugins=%d config=%s cwd=%s`, resolvedPluginsCount, String(postcssOptions.config), String(postcssOptions.cwd));
|
|
827
|
-
} catch {}
|
|
828
|
-
return {
|
|
829
|
-
test: /\.css$/,
|
|
830
|
-
type: 'css',
|
|
831
|
-
loader: require.resolve('postcss-loader'),
|
|
832
|
-
options: {
|
|
833
|
-
postcssOptions,
|
|
834
|
-
sourceMap: 'development' === opts.mode
|
|
835
|
-
}
|
|
836
|
-
};
|
|
837
|
-
}
|
|
508
|
+
var tailwind = __webpack_require__("./webpack/plugin-css/css-tools/tailwind.ts");
|
|
509
|
+
var postcss = __webpack_require__("./webpack/plugin-css/css-tools/postcss.ts");
|
|
838
510
|
async function commonStyleLoaders(projectPath, opts) {
|
|
839
511
|
const styleLoaders = [];
|
|
840
|
-
if (
|
|
841
|
-
const maybeInstallPostCss = await
|
|
512
|
+
if ((0, postcss.A)(projectPath) || (0, tailwind.F)(projectPath) || (0, sass.fZ)(projectPath) || (0, less.K)(projectPath)) {
|
|
513
|
+
const maybeInstallPostCss = await (0, postcss.t)(projectPath, opts);
|
|
842
514
|
if (maybeInstallPostCss.loader) styleLoaders.push(maybeInstallPostCss);
|
|
843
515
|
}
|
|
844
516
|
if (opts.loader) styleLoaders.push({
|
|
@@ -850,31 +522,37 @@ exports.modules = {
|
|
|
850
522
|
});
|
|
851
523
|
return styleLoaders.filter(Boolean);
|
|
852
524
|
}
|
|
853
|
-
|
|
854
|
-
|
|
525
|
+
var is_content_script = __webpack_require__("./webpack/plugin-css/css-lib/is-content-script.ts");
|
|
526
|
+
async function cssInContentScriptLoader(projectPath, manifestPath, mode, usage = {}) {
|
|
527
|
+
const { useSass = true, useLess = true } = usage;
|
|
528
|
+
const isContentScript = (issuer)=>(0, is_content_script.z)(issuer, manifestPath);
|
|
855
529
|
const fileTypes = [
|
|
856
530
|
{
|
|
857
531
|
test: /\.css$/,
|
|
858
532
|
loader: null
|
|
859
533
|
},
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
534
|
+
...useSass ? [
|
|
535
|
+
{
|
|
536
|
+
test: /\.(sass|scss)$/,
|
|
537
|
+
exclude: /\.module\.(sass|scss)$/,
|
|
538
|
+
loader: 'sass-loader'
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
test: /\.module\.(sass|scss)$/,
|
|
542
|
+
loader: 'sass-loader'
|
|
543
|
+
}
|
|
544
|
+
] : [],
|
|
545
|
+
...useLess ? [
|
|
546
|
+
{
|
|
547
|
+
test: /\.less$/,
|
|
548
|
+
exclude: /\.module\.less$/,
|
|
549
|
+
loader: 'less-loader'
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
test: /\.module\.less$/,
|
|
553
|
+
loader: 'less-loader'
|
|
554
|
+
}
|
|
555
|
+
] : []
|
|
878
556
|
];
|
|
879
557
|
const rules = await Promise.all(fileTypes.map(async ({ test, exclude, loader })=>{
|
|
880
558
|
const baseConfig = {
|
|
@@ -892,7 +570,7 @@ exports.modules = {
|
|
|
892
570
|
mode: mode
|
|
893
571
|
})
|
|
894
572
|
};
|
|
895
|
-
const loaderOptions = 'sass-loader' === loader ?
|
|
573
|
+
const loaderOptions = 'sass-loader' === loader ? (0, sass.mF)(projectPath, mode) : {
|
|
896
574
|
sourceMap: true
|
|
897
575
|
};
|
|
898
576
|
return {
|
|
@@ -906,36 +584,41 @@ exports.modules = {
|
|
|
906
584
|
}));
|
|
907
585
|
return rules;
|
|
908
586
|
}
|
|
909
|
-
async function cssInHtmlLoader(projectPath, mode, manifestPath) {
|
|
910
|
-
const
|
|
587
|
+
async function cssInHtmlLoader(projectPath, mode, manifestPath, usage = {}) {
|
|
588
|
+
const { useSass = true, useLess = true } = usage;
|
|
589
|
+
const isNotContentScript = (issuer)=>!(0, is_content_script.z)(issuer, manifestPath);
|
|
911
590
|
const fileTypes = [
|
|
912
591
|
{
|
|
913
592
|
test: /\.css$/,
|
|
914
593
|
type: 'css',
|
|
915
594
|
loader: null
|
|
916
595
|
},
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
596
|
+
...useSass ? [
|
|
597
|
+
{
|
|
598
|
+
test: /\.(sass|scss)$/,
|
|
599
|
+
exclude: /\.module\.(sass|scss)$/,
|
|
600
|
+
type: 'css',
|
|
601
|
+
loader: 'sass-loader'
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
test: /\.module\.(sass|scss)$/,
|
|
605
|
+
type: 'css/module',
|
|
606
|
+
loader: 'sass-loader'
|
|
607
|
+
}
|
|
608
|
+
] : [],
|
|
609
|
+
...useLess ? [
|
|
610
|
+
{
|
|
611
|
+
test: /\.less$/,
|
|
612
|
+
exclude: /\.module\.less$/,
|
|
613
|
+
type: 'css',
|
|
614
|
+
loader: 'less-loader'
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
test: /\.module\.less$/,
|
|
618
|
+
type: 'css/module',
|
|
619
|
+
loader: 'less-loader'
|
|
620
|
+
}
|
|
621
|
+
] : []
|
|
939
622
|
];
|
|
940
623
|
const rules = await Promise.all(fileTypes.map(async ({ test, exclude, type, loader })=>{
|
|
941
624
|
const baseConfig = {
|
|
@@ -950,7 +633,7 @@ exports.modules = {
|
|
|
950
633
|
mode: mode
|
|
951
634
|
})
|
|
952
635
|
};
|
|
953
|
-
const loaderOptions = 'sass-loader' === loader ?
|
|
636
|
+
const loaderOptions = 'sass-loader' === loader ? (0, sass.mF)(projectPath, mode) : {
|
|
954
637
|
sourceMap: true
|
|
955
638
|
};
|
|
956
639
|
return {
|
|
@@ -977,17 +660,25 @@ exports.modules = {
|
|
|
977
660
|
class CssPlugin {
|
|
978
661
|
async configureOptions(compiler) {
|
|
979
662
|
const mode = compiler.options.mode || 'development';
|
|
980
|
-
const projectPath = compiler.options.context;
|
|
663
|
+
const projectPath = compiler.options.context || process.cwd();
|
|
981
664
|
const plugins = [];
|
|
982
665
|
const manifestPath = this.manifestPath;
|
|
666
|
+
const usingSass = (0, css_lib_integrations.w)(projectPath, 'sass');
|
|
667
|
+
const usingLess = (0, css_lib_integrations.w)(projectPath, 'less');
|
|
983
668
|
const maybeInstallStylelint = await maybeUseStylelint(projectPath);
|
|
984
669
|
plugins.push(...maybeInstallStylelint);
|
|
670
|
+
const maybeInstallSass = await (0, sass.IZ)(projectPath);
|
|
671
|
+
const maybeInstallLess = await (0, less.V)(projectPath, manifestPath);
|
|
985
672
|
const loaders = [
|
|
986
|
-
...await cssInContentScriptLoader(projectPath, manifestPath, mode
|
|
987
|
-
|
|
673
|
+
...await cssInContentScriptLoader(projectPath, manifestPath, mode, {
|
|
674
|
+
useSass: usingSass,
|
|
675
|
+
useLess: usingLess
|
|
676
|
+
}),
|
|
677
|
+
...await cssInHtmlLoader(projectPath, mode, manifestPath, {
|
|
678
|
+
useSass: usingSass,
|
|
679
|
+
useLess: usingLess
|
|
680
|
+
})
|
|
988
681
|
];
|
|
989
|
-
const maybeInstallSass = await maybeUseSass(projectPath);
|
|
990
|
-
const maybeInstallLess = await maybeUseLess(projectPath, manifestPath);
|
|
991
682
|
if (maybeInstallSass.length) loaders.push({
|
|
992
683
|
test: /\.(sass|scss)$/,
|
|
993
684
|
exclude: /\.module\.(sass|scss)$/,
|
|
@@ -995,7 +686,7 @@ exports.modules = {
|
|
|
995
686
|
generator: {
|
|
996
687
|
filename: "content_scripts/[name].[contenthash:8].css"
|
|
997
688
|
},
|
|
998
|
-
issuer: (issuer)=>
|
|
689
|
+
issuer: (issuer)=>(0, is_content_script.z)(issuer, manifestPath)
|
|
999
690
|
});
|
|
1000
691
|
if (maybeInstallLess.length) loaders.push({
|
|
1001
692
|
test: /\.less$/,
|
|
@@ -1004,7 +695,7 @@ exports.modules = {
|
|
|
1004
695
|
generator: {
|
|
1005
696
|
filename: "content_scripts/[name].[contenthash:8].css"
|
|
1006
697
|
},
|
|
1007
|
-
issuer: (issuer)=>
|
|
698
|
+
issuer: (issuer)=>(0, is_content_script.z)(issuer, manifestPath)
|
|
1008
699
|
});
|
|
1009
700
|
compiler.options.plugins = [
|
|
1010
701
|
...compiler.options.plugins,
|
|
@@ -1016,20 +707,18 @@ exports.modules = {
|
|
|
1016
707
|
].filter(Boolean);
|
|
1017
708
|
if ('true' === process.env.EXTENSION_AUTHOR_MODE) {
|
|
1018
709
|
const integrations = [];
|
|
1019
|
-
const usingSass = (0, css_lib_integrations.w)(projectPath, 'sass');
|
|
1020
|
-
const usingLess = (0, css_lib_integrations.w)(projectPath, 'less');
|
|
1021
710
|
const usingTailwind = (0, css_lib_integrations.w)(projectPath, 'tailwindcss');
|
|
1022
|
-
const usingPostcss = (0, css_lib_integrations.w)(projectPath, 'postcss') || void 0 !==
|
|
711
|
+
const usingPostcss = (0, css_lib_integrations.w)(projectPath, 'postcss') || void 0 !== findPostCssConfig(projectPath) || usingSass || usingLess || usingTailwind;
|
|
1023
712
|
if (usingPostcss) integrations.push('PostCSS');
|
|
1024
713
|
if (usingSass) integrations.push('Sass');
|
|
1025
714
|
if (usingLess) integrations.push('Less');
|
|
1026
715
|
if (usingTailwind) integrations.push('Tailwind');
|
|
1027
|
-
console.log(
|
|
1028
|
-
const postcssConfig =
|
|
716
|
+
console.log(css_lib_messages.uo(integrations));
|
|
717
|
+
const postcssConfig = findPostCssConfig(projectPath);
|
|
1029
718
|
const stylelintConfig = getStylelintConfigFile(projectPath);
|
|
1030
|
-
const tailwindConfig =
|
|
719
|
+
const tailwindConfig = (0, tailwind.r)(projectPath);
|
|
1031
720
|
const browserslistSource = findBrowserslistSource(projectPath);
|
|
1032
|
-
console.log(
|
|
721
|
+
console.log(css_lib_messages.fD(postcssConfig, stylelintConfig, tailwindConfig, browserslistSource));
|
|
1033
722
|
}
|
|
1034
723
|
}
|
|
1035
724
|
async apply(compiler) {
|
|
@@ -1043,7 +732,7 @@ exports.modules = {
|
|
|
1043
732
|
}
|
|
1044
733
|
}
|
|
1045
734
|
plugin_css_define_property(CssPlugin, "name", 'plugin-css');
|
|
1046
|
-
const
|
|
735
|
+
const postCssConfigFiles = [
|
|
1047
736
|
'.postcssrc',
|
|
1048
737
|
'.postcssrc.json',
|
|
1049
738
|
'.postcssrc.yaml',
|
|
@@ -1053,8 +742,8 @@ exports.modules = {
|
|
|
1053
742
|
'postcss.config.js',
|
|
1054
743
|
'postcss.config.cjs'
|
|
1055
744
|
];
|
|
1056
|
-
function
|
|
1057
|
-
for (const configFile of
|
|
745
|
+
function findPostCssConfig(projectPath) {
|
|
746
|
+
for (const configFile of postCssConfigFiles){
|
|
1058
747
|
const configPath = external_path_.join(projectPath, configFile);
|
|
1059
748
|
if (external_fs_.existsSync(configPath)) return configPath;
|
|
1060
749
|
}
|
|
@@ -1198,351 +887,12 @@ exports.modules = {
|
|
|
1198
887
|
}
|
|
1199
888
|
}
|
|
1200
889
|
plugin_static_assets_define_property(StaticAssetsPlugin, "name", 'plugin-static-assets');
|
|
1201
|
-
var
|
|
1202
|
-
var
|
|
1203
|
-
|
|
1204
|
-
let cachedPreactRefreshPlugin;
|
|
1205
|
-
function getPreactRefreshPlugin() {
|
|
1206
|
-
if (cachedPreactRefreshPlugin) return cachedPreactRefreshPlugin;
|
|
1207
|
-
try {
|
|
1208
|
-
const mod = __webpack_require__("@rspack/plugin-preact-refresh");
|
|
1209
|
-
const plugin = mod && mod.default || mod;
|
|
1210
|
-
cachedPreactRefreshPlugin = plugin;
|
|
1211
|
-
return cachedPreactRefreshPlugin;
|
|
1212
|
-
} catch {}
|
|
1213
|
-
}
|
|
1214
|
-
function isUsingPreact(projectPath) {
|
|
1215
|
-
if ((0, frameworks_lib_integrations.ws)(projectPath, 'preact')) {
|
|
1216
|
-
if (!preact_userMessageDelivered) {
|
|
1217
|
-
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(`${external_pintor_default().brightMagenta('►►► Author says')} ${js_frameworks_lib_messages.zA('Preact')}`);
|
|
1218
|
-
preact_userMessageDelivered = true;
|
|
1219
|
-
}
|
|
1220
|
-
return true;
|
|
1221
|
-
}
|
|
1222
|
-
return false;
|
|
1223
|
-
}
|
|
1224
|
-
async function maybeUsePreact(projectPath) {
|
|
1225
|
-
if (!isUsingPreact(projectPath)) return;
|
|
1226
|
-
try {
|
|
1227
|
-
require.resolve('@rspack/plugin-preact-refresh');
|
|
1228
|
-
} catch (e) {
|
|
1229
|
-
const preactDependencies = [
|
|
1230
|
-
'@prefresh/core',
|
|
1231
|
-
'@prefresh/utils',
|
|
1232
|
-
'@rspack/plugin-preact-refresh',
|
|
1233
|
-
'preact'
|
|
1234
|
-
];
|
|
1235
|
-
await (0, frameworks_lib_integrations.tm)('Preact', preactDependencies);
|
|
1236
|
-
console.log(js_frameworks_lib_messages.Jv('Preact'));
|
|
1237
|
-
process.exit(0);
|
|
1238
|
-
}
|
|
1239
|
-
const PreactRefreshPlugin = getPreactRefreshPlugin();
|
|
1240
|
-
if (!PreactRefreshPlugin) throw new Error('[Preact] @rspack/plugin-preact-refresh is installed but its plugin could not be resolved.');
|
|
1241
|
-
const preactPlugins = [
|
|
1242
|
-
new PreactRefreshPlugin({})
|
|
1243
|
-
];
|
|
1244
|
-
return {
|
|
1245
|
-
plugins: preactPlugins,
|
|
1246
|
-
loaders: void 0,
|
|
1247
|
-
alias: {
|
|
1248
|
-
react: 'preact/compat',
|
|
1249
|
-
'react-dom/test-utils': 'preact/test-utils',
|
|
1250
|
-
'react-dom': 'preact/compat',
|
|
1251
|
-
'react/jsx-runtime': 'preact/jsx-runtime'
|
|
1252
|
-
}
|
|
1253
|
-
};
|
|
1254
|
-
}
|
|
1255
|
-
let react_userMessageDelivered = false;
|
|
1256
|
-
let cachedReactRefreshPlugin;
|
|
1257
|
-
function getReactRefreshPlugin() {
|
|
1258
|
-
if (cachedReactRefreshPlugin) return cachedReactRefreshPlugin;
|
|
1259
|
-
try {
|
|
1260
|
-
const mod = __webpack_require__("@rspack/plugin-react-refresh");
|
|
1261
|
-
const plugin = mod && mod.default || mod;
|
|
1262
|
-
cachedReactRefreshPlugin = plugin;
|
|
1263
|
-
return cachedReactRefreshPlugin;
|
|
1264
|
-
} catch {}
|
|
1265
|
-
}
|
|
1266
|
-
function isUsingReact(projectPath) {
|
|
1267
|
-
if ((0, frameworks_lib_integrations.ws)(projectPath, 'react')) {
|
|
1268
|
-
if (!react_userMessageDelivered) {
|
|
1269
|
-
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(`${external_pintor_default().brightMagenta('►►► Author says')} ${js_frameworks_lib_messages.zA('React')}`);
|
|
1270
|
-
react_userMessageDelivered = true;
|
|
1271
|
-
}
|
|
1272
|
-
return true;
|
|
1273
|
-
}
|
|
1274
|
-
return false;
|
|
1275
|
-
}
|
|
1276
|
-
async function maybeUseReact(projectPath) {
|
|
1277
|
-
if (!isUsingReact(projectPath)) return;
|
|
1278
|
-
try {
|
|
1279
|
-
require.resolve('react-refresh');
|
|
1280
|
-
} catch (e) {
|
|
1281
|
-
const reactDependencies = [
|
|
1282
|
-
'react-refresh',
|
|
1283
|
-
'@rspack/plugin-react-refresh'
|
|
1284
|
-
];
|
|
1285
|
-
await (0, frameworks_lib_integrations.tm)('React', reactDependencies);
|
|
1286
|
-
console.log(js_frameworks_lib_messages.Jv('React'));
|
|
1287
|
-
process.exit(0);
|
|
1288
|
-
}
|
|
1289
|
-
const ReactRefreshPlugin = getReactRefreshPlugin();
|
|
1290
|
-
if (!ReactRefreshPlugin) throw new Error('[React] @rspack/plugin-react-refresh is installed but its plugin could not be resolved.');
|
|
1291
|
-
const reactPlugins = [
|
|
1292
|
-
new ReactRefreshPlugin({
|
|
1293
|
-
overlay: false
|
|
1294
|
-
})
|
|
1295
|
-
];
|
|
1296
|
-
const requireFromProject = (0, external_module_.createRequire)(external_path_.join(projectPath, 'package.json'));
|
|
1297
|
-
let reactPath;
|
|
1298
|
-
let reactDomPath;
|
|
1299
|
-
let reactDomClientPath;
|
|
1300
|
-
let jsxRuntimePath;
|
|
1301
|
-
try {
|
|
1302
|
-
reactPath = requireFromProject.resolve('react');
|
|
1303
|
-
} catch {}
|
|
1304
|
-
try {
|
|
1305
|
-
reactDomPath = requireFromProject.resolve('react-dom');
|
|
1306
|
-
} catch {}
|
|
1307
|
-
try {
|
|
1308
|
-
reactDomClientPath = requireFromProject.resolve('react-dom/client');
|
|
1309
|
-
} catch {}
|
|
1310
|
-
try {
|
|
1311
|
-
jsxRuntimePath = requireFromProject.resolve('react/jsx-runtime');
|
|
1312
|
-
} catch {}
|
|
1313
|
-
const alias = {};
|
|
1314
|
-
if (reactPath) alias['react$'] = reactPath;
|
|
1315
|
-
if (reactDomPath) alias['react-dom$'] = reactDomPath;
|
|
1316
|
-
if (reactDomClientPath) alias['react-dom/client'] = reactDomClientPath;
|
|
1317
|
-
if (jsxRuntimePath) alias['react/jsx-runtime'] = jsxRuntimePath;
|
|
1318
|
-
return {
|
|
1319
|
-
plugins: reactPlugins,
|
|
1320
|
-
loaders: void 0,
|
|
1321
|
-
alias
|
|
1322
|
-
};
|
|
1323
|
-
}
|
|
1324
|
-
var external_url_ = __webpack_require__("url");
|
|
1325
|
-
let load_loader_options_userMessageDelivered = false;
|
|
1326
|
-
function isAuthorMode() {
|
|
1327
|
-
const v = String(process.env.EXTENSION_AUTHOR_MODE || '').trim().toLowerCase();
|
|
1328
|
-
return 'true' === v || '1' === v || 'development' === v || 'dev' === v;
|
|
1329
|
-
}
|
|
1330
|
-
function resolveLoaderConfigPath(projectPath, framework) {
|
|
1331
|
-
const candidates = [
|
|
1332
|
-
external_path_.join(projectPath, `${framework}.loader.ts`),
|
|
1333
|
-
external_path_.join(projectPath, `${framework}.loader.mts`),
|
|
1334
|
-
external_path_.join(projectPath, `${framework}.loader.js`),
|
|
1335
|
-
external_path_.join(projectPath, `${framework}.loader.mjs`)
|
|
1336
|
-
];
|
|
1337
|
-
return candidates.find((p)=>external_fs_.existsSync(p)) || null;
|
|
1338
|
-
}
|
|
1339
|
-
async function loadLoaderOptions(projectPath, framework) {
|
|
1340
|
-
const configPath = resolveLoaderConfigPath(projectPath, framework);
|
|
1341
|
-
if (configPath) {
|
|
1342
|
-
if (!load_loader_options_userMessageDelivered && isAuthorMode()) {
|
|
1343
|
-
const display = external_path_.basename(configPath);
|
|
1344
|
-
console.log(js_frameworks_lib_messages.Ty(display));
|
|
1345
|
-
load_loader_options_userMessageDelivered = true;
|
|
1346
|
-
}
|
|
1347
|
-
try {
|
|
1348
|
-
const module = await import((0, external_url_.pathToFileURL)(configPath).href);
|
|
1349
|
-
return module.default || module;
|
|
1350
|
-
} catch (err) {
|
|
1351
|
-
const error = err;
|
|
1352
|
-
console.error(`Error loading ${framework} loader options: ${error.message}`);
|
|
1353
|
-
throw err;
|
|
1354
|
-
}
|
|
1355
|
-
}
|
|
1356
|
-
return null;
|
|
1357
|
-
}
|
|
1358
|
-
let vue_userMessageDelivered = false;
|
|
1359
|
-
let cachedVueLoaderPlugin;
|
|
1360
|
-
function getVueLoaderPlugin() {
|
|
1361
|
-
if (cachedVueLoaderPlugin) return cachedVueLoaderPlugin;
|
|
1362
|
-
try {
|
|
1363
|
-
const mod = __webpack_require__("vue-loader");
|
|
1364
|
-
const plugin = mod && mod.VueLoaderPlugin || mod && mod.default && mod.default.VueLoaderPlugin;
|
|
1365
|
-
if (plugin) {
|
|
1366
|
-
cachedVueLoaderPlugin = plugin;
|
|
1367
|
-
return cachedVueLoaderPlugin;
|
|
1368
|
-
}
|
|
1369
|
-
} catch {}
|
|
1370
|
-
}
|
|
1371
|
-
function isUsingVue(projectPath) {
|
|
1372
|
-
const using = (0, frameworks_lib_integrations.ws)(projectPath, 'vue');
|
|
1373
|
-
if (using && !vue_userMessageDelivered) {
|
|
1374
|
-
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(`${external_pintor_default().brightMagenta('►►► Author says')} ${js_frameworks_lib_messages.zA('Vue')}`);
|
|
1375
|
-
vue_userMessageDelivered = true;
|
|
1376
|
-
}
|
|
1377
|
-
return using;
|
|
1378
|
-
}
|
|
1379
|
-
async function maybeUseVue(projectPath) {
|
|
1380
|
-
if (!isUsingVue(projectPath)) return;
|
|
1381
|
-
try {
|
|
1382
|
-
require.resolve('vue-loader');
|
|
1383
|
-
} catch (e) {
|
|
1384
|
-
const vueDependencies = [
|
|
1385
|
-
'vue-loader',
|
|
1386
|
-
'@vue/compiler-sfc'
|
|
1387
|
-
];
|
|
1388
|
-
await (0, frameworks_lib_integrations.tm)('Vue', vueDependencies);
|
|
1389
|
-
console.log(js_frameworks_lib_messages.Jv('Vue'));
|
|
1390
|
-
process.exit(0);
|
|
1391
|
-
}
|
|
1392
|
-
const VueLoaderPlugin = getVueLoaderPlugin();
|
|
1393
|
-
if (!VueLoaderPlugin) throw new Error('[Vue] vue-loader is installed but VueLoaderPlugin could not be resolved.');
|
|
1394
|
-
const customOptions = await loadLoaderOptions(projectPath, 'vue');
|
|
1395
|
-
const defaultLoaders = [
|
|
1396
|
-
{
|
|
1397
|
-
test: /\.vue$/,
|
|
1398
|
-
loader: require.resolve('vue-loader'),
|
|
1399
|
-
options: {
|
|
1400
|
-
experimentalInlineMatchResource: true,
|
|
1401
|
-
...customOptions || {}
|
|
1402
|
-
},
|
|
1403
|
-
include: projectPath,
|
|
1404
|
-
exclude: /node_modules/
|
|
1405
|
-
}
|
|
1406
|
-
];
|
|
1407
|
-
const defaultPlugins = [
|
|
1408
|
-
new VueLoaderPlugin()
|
|
1409
|
-
];
|
|
1410
|
-
return {
|
|
1411
|
-
plugins: defaultPlugins,
|
|
1412
|
-
loaders: defaultLoaders,
|
|
1413
|
-
alias: void 0
|
|
1414
|
-
};
|
|
1415
|
-
}
|
|
890
|
+
var preact = __webpack_require__("./webpack/plugin-js-frameworks/js-tools/preact.ts");
|
|
891
|
+
var react = __webpack_require__("./webpack/plugin-js-frameworks/js-tools/react.ts");
|
|
892
|
+
var vue = __webpack_require__("./webpack/plugin-js-frameworks/js-tools/vue.ts");
|
|
1416
893
|
var typescript = __webpack_require__("./webpack/plugin-js-frameworks/js-tools/typescript.ts");
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
try {
|
|
1420
|
-
return require.resolve(id, {
|
|
1421
|
-
paths: [
|
|
1422
|
-
projectPath,
|
|
1423
|
-
process.cwd()
|
|
1424
|
-
]
|
|
1425
|
-
});
|
|
1426
|
-
} catch {
|
|
1427
|
-
return;
|
|
1428
|
-
}
|
|
1429
|
-
}
|
|
1430
|
-
function isUsingSvelte(projectPath) {
|
|
1431
|
-
const using = (0, frameworks_lib_integrations.ws)(projectPath, 'svelte');
|
|
1432
|
-
if (using && !svelte_userMessageDelivered) {
|
|
1433
|
-
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(js_frameworks_lib_messages.zA('Svelte'));
|
|
1434
|
-
svelte_userMessageDelivered = true;
|
|
1435
|
-
}
|
|
1436
|
-
return using;
|
|
1437
|
-
}
|
|
1438
|
-
async function maybeUseSvelte(projectPath, mode) {
|
|
1439
|
-
if (!isUsingSvelte(projectPath)) return;
|
|
1440
|
-
try {
|
|
1441
|
-
resolveFromProject('svelte-loader', projectPath) || require.resolve('svelte-loader');
|
|
1442
|
-
} catch (e) {
|
|
1443
|
-
const typeScriptDependencies = [
|
|
1444
|
-
"typescript"
|
|
1445
|
-
];
|
|
1446
|
-
await (0, frameworks_lib_integrations.tm)('TypeScript', typeScriptDependencies);
|
|
1447
|
-
const svelteDependencies = [
|
|
1448
|
-
'svelte-loader'
|
|
1449
|
-
];
|
|
1450
|
-
await (0, frameworks_lib_integrations.tm)('Svelte', svelteDependencies);
|
|
1451
|
-
console.log(js_frameworks_lib_messages.Jv('Svelte'));
|
|
1452
|
-
process.exit(0);
|
|
1453
|
-
}
|
|
1454
|
-
try {
|
|
1455
|
-
require.resolve("typescript", {
|
|
1456
|
-
paths: [
|
|
1457
|
-
projectPath,
|
|
1458
|
-
process.cwd()
|
|
1459
|
-
]
|
|
1460
|
-
});
|
|
1461
|
-
} catch (e) {
|
|
1462
|
-
const typeScriptDependencies = [
|
|
1463
|
-
"typescript"
|
|
1464
|
-
];
|
|
1465
|
-
await (0, frameworks_lib_integrations.tm)('TypeScript', typeScriptDependencies);
|
|
1466
|
-
console.log(js_frameworks_lib_messages.Jv('TypeScript'));
|
|
1467
|
-
process.exit(0);
|
|
1468
|
-
}
|
|
1469
|
-
const customOptions = await loadLoaderOptions(projectPath, 'svelte');
|
|
1470
|
-
const svelteLoaderPath = resolveFromProject('svelte-loader', projectPath) || require.resolve('svelte-loader');
|
|
1471
|
-
const defaultLoaders = [
|
|
1472
|
-
{
|
|
1473
|
-
test: /\.svelte\.ts$/,
|
|
1474
|
-
use: [
|
|
1475
|
-
svelteLoaderPath
|
|
1476
|
-
],
|
|
1477
|
-
include: projectPath,
|
|
1478
|
-
exclude: /node_modules/
|
|
1479
|
-
},
|
|
1480
|
-
{
|
|
1481
|
-
test: /\.(svelte|svelte\.js)$/,
|
|
1482
|
-
use: {
|
|
1483
|
-
loader: svelteLoaderPath,
|
|
1484
|
-
options: {
|
|
1485
|
-
emitCss: true,
|
|
1486
|
-
compilerOptions: {
|
|
1487
|
-
dev: 'development' === mode
|
|
1488
|
-
},
|
|
1489
|
-
hotReload: 'development' === mode,
|
|
1490
|
-
...customOptions || {}
|
|
1491
|
-
}
|
|
1492
|
-
},
|
|
1493
|
-
include: projectPath,
|
|
1494
|
-
exclude: /node_modules/
|
|
1495
|
-
},
|
|
1496
|
-
{
|
|
1497
|
-
test: /[\\/]node_modules[\\/]svelte[\\/].*\.mjs$/,
|
|
1498
|
-
resolve: {
|
|
1499
|
-
fullySpecified: false
|
|
1500
|
-
}
|
|
1501
|
-
}
|
|
1502
|
-
];
|
|
1503
|
-
const alias = void 0;
|
|
1504
|
-
const resolverPlugin = {
|
|
1505
|
-
apply (compiler) {
|
|
1506
|
-
const existingMainFields = compiler.options.resolve && compiler.options.resolve.mainFields || [];
|
|
1507
|
-
const existingConditionNames = compiler.options.resolve && (compiler.options.resolve.conditionNames || compiler.options.resolve.conditions) || [];
|
|
1508
|
-
const existingExtensions = compiler.options.resolve && compiler.options.resolve.extensions || [];
|
|
1509
|
-
const existingAlias = compiler.options.resolve && compiler.options.resolve.alias || {};
|
|
1510
|
-
const existingModules = compiler.options.resolve && compiler.options.resolve.modules || [];
|
|
1511
|
-
const nextMainFields = [
|
|
1512
|
-
'svelte',
|
|
1513
|
-
'browser',
|
|
1514
|
-
'module',
|
|
1515
|
-
'main',
|
|
1516
|
-
...existingMainFields
|
|
1517
|
-
];
|
|
1518
|
-
const dedupe = (arr)=>Array.from(new Set(arr));
|
|
1519
|
-
compiler.options.resolve = {
|
|
1520
|
-
...compiler.options.resolve,
|
|
1521
|
-
mainFields: dedupe(nextMainFields),
|
|
1522
|
-
conditionNames: dedupe([
|
|
1523
|
-
'svelte',
|
|
1524
|
-
...existingConditionNames
|
|
1525
|
-
]),
|
|
1526
|
-
extensions: dedupe([
|
|
1527
|
-
'.svelte',
|
|
1528
|
-
...existingExtensions
|
|
1529
|
-
]),
|
|
1530
|
-
alias: existingAlias,
|
|
1531
|
-
modules: dedupe([
|
|
1532
|
-
external_path_.join(projectPath, 'node_modules'),
|
|
1533
|
-
...existingModules
|
|
1534
|
-
])
|
|
1535
|
-
};
|
|
1536
|
-
}
|
|
1537
|
-
};
|
|
1538
|
-
return {
|
|
1539
|
-
plugins: [
|
|
1540
|
-
resolverPlugin
|
|
1541
|
-
],
|
|
1542
|
-
loaders: defaultLoaders,
|
|
1543
|
-
alias
|
|
1544
|
-
};
|
|
1545
|
-
}
|
|
894
|
+
var svelte = __webpack_require__("./webpack/plugin-js-frameworks/js-tools/svelte.ts");
|
|
895
|
+
var js_frameworks_lib_messages = __webpack_require__("./webpack/plugin-js-frameworks/js-frameworks-lib/messages.ts");
|
|
1546
896
|
function plugin_js_frameworks_define_property(obj, key, value) {
|
|
1547
897
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
1548
898
|
value: value,
|
|
@@ -1557,10 +907,10 @@ exports.modules = {
|
|
|
1557
907
|
async configureOptions(compiler) {
|
|
1558
908
|
const mode = compiler.options.mode || 'development';
|
|
1559
909
|
const projectPath = compiler.options.context;
|
|
1560
|
-
const maybeInstallReact = await
|
|
1561
|
-
const maybeInstallPreact = await
|
|
1562
|
-
const maybeInstallVue = await
|
|
1563
|
-
const maybeInstallSvelte = await
|
|
910
|
+
const maybeInstallReact = await (0, react.b)(projectPath);
|
|
911
|
+
const maybeInstallPreact = await (0, preact.b)(projectPath);
|
|
912
|
+
const maybeInstallVue = await (0, vue.K)(projectPath);
|
|
913
|
+
const maybeInstallSvelte = await (0, svelte.X)(projectPath, mode);
|
|
1564
914
|
const tsConfigPath = (0, typescript.hB)(projectPath);
|
|
1565
915
|
const manifestDir = external_path_.dirname(this.manifestPath);
|
|
1566
916
|
const tsRoot = tsConfigPath ? external_path_.dirname(tsConfigPath) : manifestDir;
|
|
@@ -1616,8 +966,8 @@ exports.modules = {
|
|
|
1616
966
|
jsc: {
|
|
1617
967
|
parser: {
|
|
1618
968
|
syntax: preferTypeScript ? "typescript" : "ecmascript",
|
|
1619
|
-
tsx: preferTypeScript ? true : (0, typescript.eE)(projectPath) && (
|
|
1620
|
-
jsx: !preferTypeScript && (
|
|
969
|
+
tsx: preferTypeScript ? true : (0, typescript.eE)(projectPath) && ((0, react.S)(projectPath) || (0, preact.K)(projectPath)),
|
|
970
|
+
jsx: !preferTypeScript && ((0, react.S)(projectPath) || (0, preact.K)(projectPath)),
|
|
1621
971
|
dynamicImport: true
|
|
1622
972
|
},
|
|
1623
973
|
transform: {
|
|
@@ -1626,7 +976,7 @@ exports.modules = {
|
|
|
1626
976
|
refresh: 'development' === mode,
|
|
1627
977
|
runtime: 'automatic',
|
|
1628
978
|
importSource: 'react',
|
|
1629
|
-
...
|
|
979
|
+
...(0, preact.K)(projectPath) ? {
|
|
1630
980
|
pragma: 'h',
|
|
1631
981
|
pragmaFrag: 'Fragment',
|
|
1632
982
|
throwIfNamespace: true,
|