Skip to content

Commit

Permalink
Remove (break) the dynamic import in the 4 bundles that come with utils
Browse files Browse the repository at this point in the history
  • Loading branch information
jackocnr committed Jul 10, 2024
1 parent ffb4d20 commit 231a13d
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ module.exports = function(grunt) {
// just images
grunt.registerTask('img', ['responsive_images:retina', 'exec:evenizer', 'responsive_images:regular', 'sprite', 'imagemin', 'generate-scss-metadata']);
// just javascript
grunt.registerTask('js', ['shell:eslint', 'shell:genTsDeclaration', 'shell:genReactTsDeclaration', 'shell:buildJs', 'replace', 'react_with_utils', 'shell:buildReact']);
grunt.registerTask('js', ['shell:eslint', 'shell:genTsDeclaration', 'shell:genReactTsDeclaration', 'shell:buildJs', 'replace', 'shell:buildReact', 'replace:removeImport']);
// just react
grunt.registerTask('react', ['react_with_utils', 'shell:buildReact']);
grunt.registerTask('react', ['replace:reactWithUtils', 'shell:buildReact', 'replace:removeImport']);

// Travis CI
grunt.registerTask('travis', ['jasmine']);
Expand Down
2 changes: 1 addition & 1 deletion build/js/intlTelInputWithUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2719,7 +2719,7 @@ var factoryOutput = (() => {
if (!intlTelInput.utils && !intlTelInput.startedLoadingUtilsScript) {
intlTelInput.startedLoadingUtilsScript = true;
return new Promise((resolve, reject) => {
import(
import_INTENTIONALLY_BROKEN(
/* webpackIgnore: true */
path
).then(({ default: utils2 }) => {
Expand Down
2 changes: 1 addition & 1 deletion build/js/intlTelInputWithUtils.min.js

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions grunt/react_with_utils.js

This file was deleted.

40 changes: 40 additions & 0 deletions grunt/replace.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,46 @@ module.exports = function(grunt) {
files: {
'.github/ISSUE_TEMPLATE.md': '.github/ISSUE_TEMPLATE.md'
}
},


/**************
* Generate reactWithUtils.tsx
**************/
reactWithUtils: {
options: {
patterns: [
{
match: /import intlTelInput from \"\.\.\/intl\-tel\-input\"\;/,
replacement: '//* THIS FILE IS AUTO-GENERATED. DO NOT EDIT.\nimport intlTelInput from "./intlTelInputWithUtils";'
}
]
},
files: {
'react/src/intl-tel-input/reactWithUtils.tsx': 'react/src/intl-tel-input/react.tsx',
}
},


/**************
* Remove (break) the dynamic import statement
* in the 4 bundles that already include utils as it will never be used, and sometimes causes problems with bundlers
**************/
removeImport: {
options: {
patterns: [
{
match: /import\(/,
replacement: 'import_INTENTIONALLY_BROKEN('
}
]
},
files: {
'build/js/intlTelInputWithUtils.js': 'build/js/intlTelInputWithUtils.js',
'build/js/intlTelInputWithUtils.min.js': 'build/js/intlTelInputWithUtils.min.js',
'react/build/IntlTelInputWithUtils.js': 'react/build/IntlTelInputWithUtils.js',
'react/build/IntlTelInputWithUtils.cjs': 'react/build/IntlTelInputWithUtils.cjs',
}
}
};
};
2 changes: 1 addition & 1 deletion react/build/IntlTelInputWithUtils.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2715,7 +2715,7 @@ var loadUtils = (path) => {
if (!intlTelInput.utils && !intlTelInput.startedLoadingUtilsScript) {
intlTelInput.startedLoadingUtilsScript = true;
return new Promise((resolve, reject) => {
import(
import_INTENTIONALLY_BROKEN(
/* webpackIgnore: true */
path
).then(({ default: utils2 }) => {
Expand Down
2 changes: 1 addition & 1 deletion react/build/IntlTelInputWithUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2679,7 +2679,7 @@ var loadUtils = (path) => {
if (!intlTelInput.utils && !intlTelInput.startedLoadingUtilsScript) {
intlTelInput.startedLoadingUtilsScript = true;
return new Promise((resolve, reject) => {
import(
import_INTENTIONALLY_BROKEN(
/* webpackIgnore: true */
path
).then(({ default: utils2 }) => {
Expand Down

0 comments on commit 231a13d

Please sign in to comment.