Skip to content

Commit

Permalink
Add webpack ignore (#6359)
Browse files Browse the repository at this point in the history
  • Loading branch information
marklundin authored and Martin Valigursky committed May 14, 2024
1 parent 692f2a7 commit 9751ca8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions utils/plugins/rollup-dynamic.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,18 @@ export function dynamicImportLegacyBrowserSupport() {
}

/**
* This rollup plugin transform code with import statements and adds a \/* vite-ignore *\/ comment to supress vite warnings
* This rollup plugin transform code with import statements and adds a \/* vite-ignore *\/ comment to suppress bundler warnings
* generated from dynamic-import-vars {@link https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations}
* {@link https://webpack.js.org/api/module-methods/#dynamic-expressions-in-import}
*
* @returns {import('rollup').Plugin} The rollup plugin
*/
export function dynamicImportViteSupress() {
export function dynamicImportBundlerSuppress() {
return {
name: 'dynamic-import-vite-suppress',
name: 'dynamic-import-bundler-suppress',
transform(code, id) {
return {
code: code.replace(/import\(([^'])/g, 'import(/* @vite-ignore */$1'),
code: code.replace(/import\(([^'])/g, 'import(/* @vite-ignore */ /* webpackIgnore: true */ $1'),
map: null
};
}
Expand Down
4 changes: 2 additions & 2 deletions utils/rollup-build-target.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { visualizer } from 'rollup-plugin-visualizer';
import { shaderChunks } from './plugins/rollup-shader-chunks.mjs';
import { engineLayerImportValidation } from './plugins/rollup-import-validation.mjs';
import { spacesToTabs } from './plugins/rollup-spaces-to-tabs.mjs';
import { dynamicImportLegacyBrowserSupport, dynamicImportViteSupress } from './plugins/rollup-dynamic.mjs';
import { dynamicImportLegacyBrowserSupport, dynamicImportBundlerSuppress } from './plugins/rollup-dynamic.mjs';
import { treeshakeIgnore } from './plugins/rollup-treeshake-ignore.mjs';

import { version, revision } from './rollup-version-revision.mjs';
Expand Down Expand Up @@ -210,7 +210,7 @@ function buildTarget({ moduleFormat, buildType, input = 'src/index.js', dir = 'b
isDebug ? engineLayerImportValidation(input) : undefined,
!isDebug ? strip({ functions: STRIP_FUNCTIONS }) : undefined,
babel(babelOptions(isDebug, isUMD)),
!isUMD ? dynamicImportViteSupress() : undefined,
!isUMD ? dynamicImportBundlerSuppress() : undefined,
!isDebug ? spacesToTabs() : undefined
]
};
Expand Down

0 comments on commit 9751ca8

Please sign in to comment.