@mpxjs/webpack-plugin 2.9.28 → 2.9.30

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.
@@ -0,0 +1,38 @@
1
+ const ModuleDependency = require('webpack/lib/dependencies/ModuleDependency')
2
+
3
+ class ImportDependencyTemplate extends (
4
+ ModuleDependency.Template
5
+ ) {
6
+ /**
7
+ * @param {Dependency} dependency the dependency for which the template should be applied
8
+ * @param {ReplaceSource} source the current replace source which can be modified
9
+ * @param {DependencyTemplateContext} templateContext the context object
10
+ * @returns {void}
11
+ */
12
+ apply (
13
+ dependency,
14
+ source,
15
+ { runtimeTemplate, module, moduleGraph, chunkGraph, runtimeRequirements }
16
+ ) {
17
+ const dep = /** @type {ImportDependency} */ (dependency)
18
+ const block = /** @type {AsyncDependenciesBlock} */ (
19
+ moduleGraph.getParentBlock(dep)
20
+ )
21
+ let content = runtimeTemplate.moduleNamespacePromise({
22
+ chunkGraph,
23
+ block: block,
24
+ module: /** @type {Module} */ (moduleGraph.getModule(dep)),
25
+ request: dep.request,
26
+ strict: /** @type {BuildMeta} */ (module.buildMeta).strictHarmonyModule,
27
+ message: 'import()',
28
+ runtimeRequirements
29
+ })
30
+ // replace fakeType by 9 to fix require.async to commonjs2 module like 'module.exports = function(){...}'
31
+ content = content.replace(/(__webpack_require__\.t\.bind\(.+,\s*)(\d+)(\s*\))/, (_, p1, p2, p3) => {
32
+ return p1 + '9' + p3
33
+ })
34
+ source.replace(dep.range[0], dep.range[1] - 1, content)
35
+ }
36
+ }
37
+
38
+ module.exports = ImportDependencyTemplate
package/lib/index.js CHANGED
@@ -15,6 +15,7 @@ const JavascriptModulesPlugin = require('webpack/lib/javascript/JavascriptModule
15
15
  const FlagEntryExportAsUsedPlugin = require('webpack/lib/FlagEntryExportAsUsedPlugin')
16
16
  const FileSystemInfo = require('webpack/lib/FileSystemInfo')
17
17
  const ImportDependency = require('webpack/lib/dependencies/ImportDependency')
18
+ const ImportDependencyTemplate = require('./dependencies/ImportDependencyTemplate')
18
19
  const AsyncDependenciesBlock = require('webpack/lib/AsyncDependenciesBlock')
19
20
  const normalize = require('./utils/normalize')
20
21
  const toPosix = require('./utils/to-posix')
@@ -521,7 +522,10 @@ class MpxWebpackPlugin {
521
522
  })
522
523
  })
523
524
 
524
- compiler.hooks.compilation.tap('MpxWebpackPlugin ', (compilation, { normalModuleFactory }) => {
525
+ compiler.hooks.compilation.tap({
526
+ name: 'MpxWebpackPlugin',
527
+ stage: 100
528
+ }, (compilation, { normalModuleFactory }) => {
525
529
  NormalModule.getCompilationHooks(compilation).loader.tap('MpxWebpackPlugin', (loaderContext) => {
526
530
  // 设置loaderContext的minimize
527
531
  if (isProductionLikeMode(compiler.options)) {
@@ -573,6 +577,8 @@ class MpxWebpackPlugin {
573
577
 
574
578
  compilation.dependencyFactories.set(RecordVueContentDependency, new NullFactory())
575
579
  compilation.dependencyTemplates.set(RecordVueContentDependency, new RecordVueContentDependency.Template())
580
+
581
+ compilation.dependencyTemplates.set(ImportDependency, new ImportDependencyTemplate())
576
582
  })
577
583
 
578
584
  compiler.hooks.thisCompilation.tap('MpxWebpackPlugin', (compilation, { normalModuleFactory }) => {
@@ -5,7 +5,6 @@ module.exports = function ({ print }) {
5
5
  const aliEventLog = print({ platform: 'ali', tag: TAG_NAME, isError: false, type: 'event' })
6
6
  const baiduPropLog = print({ platform: 'baidu', tag: TAG_NAME, isError: false })
7
7
  const baiduEventLog = print({ platform: 'baidu', tag: TAG_NAME, isError: false, type: 'event' })
8
- const ttPropLog = print({ platform: 'bytedance', tag: TAG_NAME, isError: false })
9
8
  const ttEventLog = print({ platform: 'bytedance', tag: TAG_NAME, isError: false, type: 'event' })
10
9
  const jdPropLog = print({ platform: 'jd', tag: TAG_NAME, isError: false })
11
10
  const jdEventLog = print({ platform: 'jd', tag: TAG_NAME, isError: false, type: 'event' })
@@ -29,10 +28,6 @@ module.exports = function ({ print }) {
29
28
  test: /^(auto-focus|hold-keyboard)$/,
30
29
  swan: baiduPropLog
31
30
  },
32
- {
33
- test: /^(placeholder-class|auto-focus|confirm-type|confirm-hold|adjust-position|hold-keyboard)$/,
34
- tt: ttPropLog
35
- },
36
31
  {
37
32
  test: /^(hold-keyboard)$/,
38
33
  jd: jdPropLog
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.9.28",
3
+ "version": "2.9.30",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"
@@ -82,5 +82,5 @@
82
82
  "engines": {
83
83
  "node": ">=14.14.0"
84
84
  },
85
- "gitHead": "d573387d467bb2efb88cca627380627a1d45a4cd"
85
+ "gitHead": "5c1a417a5f474f071bd5b3ae43f668772c704ad3"
86
86
  }