-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vue): support for the loader analysis with vue-loader
feat(vue): support for the loader analysis with vue-loader feat(vue): support for the loader analysis with vue-loader feat(vue): support for the loader analysis with vue-loader fix: support for vue-loader feat(loader): support vue-loader feat(loader): support vue-loader feat(vue): support for the loader analysis with vue-loader feat(plugin): support vue-loader
- Loading branch information
Showing
14 changed files
with
651 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@rsdoctor/rspack-plugin': patch | ||
--- | ||
|
||
feat(loader): support for the loaders analysis with vue-loader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * as Chunks from './chunks'; | ||
export * as Utils from './utils'; | ||
export * as Loader from './loader'; | ||
export * as Types from '../../types'; | ||
export * as ModuleGraph from './module-graph'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './probeLoaderPlugin'; |
6 changes: 3 additions & 3 deletions
6
packages/rspack-plugin/src/probeLoader.ts → ...c/build-utils/build/loader/probeLoader.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
packages/core/src/build-utils/build/loader/probeLoaderPlugin.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { Plugin } from '@rsdoctor/types'; | ||
import type { RuleSetRules } from '@rspack/core'; | ||
import { Loader } from '@rsdoctor/utils/common'; | ||
import { Build } from '@/build-utils'; | ||
import { Utils } from '..'; | ||
|
||
const BuiltinLoaderName = 'builtin:swc-loader'; | ||
const ESMLoaderFile = '.mjs'; | ||
|
||
export class ProbeLoaderPlugin { | ||
apply(compiler: Plugin.BaseCompiler) { | ||
compiler.hooks.beforeRun.tap( | ||
{ | ||
name: 'ProbeLoaderPlugin', | ||
}, | ||
() => { | ||
this.addProbeLoader(compiler); | ||
}, | ||
); | ||
|
||
compiler.hooks.watchRun.tap( | ||
{ | ||
name: 'ProbeLoaderPlugin', | ||
}, | ||
() => { | ||
this.addProbeLoader(compiler); | ||
}, | ||
); | ||
} | ||
|
||
private addProbeLoader(compiler: Plugin.BaseCompiler) { | ||
let rules = compiler.options.module.rules as Plugin.RuleSetRule[]; | ||
|
||
if (Loader.isVue(compiler)) { | ||
compiler.options.module.rules = Utils.addProbeLoader2Rules( | ||
rules, | ||
compiler, | ||
(r: Plugin.BuildRuleSetRule) => !!r.loader || typeof r === 'string', | ||
) as RuleSetRules; | ||
return; | ||
} | ||
|
||
rules = Utils.addProbeLoader2Rules( | ||
rules, | ||
compiler, | ||
(r: Plugin.BuildRuleSetRule) => | ||
Build.Utils.getLoaderNameMatch(r, BuiltinLoaderName, true), | ||
) as Plugin.RuleSetRule[]; | ||
|
||
compiler.options.module.rules = Utils.addProbeLoader2Rules( | ||
rules, | ||
compiler, | ||
(r: Plugin.BuildRuleSetRule) => { | ||
return ( | ||
Build.Utils.getLoaderNameMatch(r, ESMLoaderFile, false) || | ||
Build.Utils.isESMLoader(r) | ||
); | ||
}, | ||
) as RuleSetRules; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './loader'; | ||
export * from './plugin'; | ||
export * from './parseBundle'; | ||
export * from '../loader/probeLoader'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.