Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/plugin/__test__/__snapshots__/test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,7 @@ exports[`imports import-multiple.js 1`] = `
`;

exports[`imports import-remove-fileext.js 1`] = `
"sap.ui.define(["array-flatten/dist/index"], function (__array_flatten_dist_indexjs) {
"sap.ui.define(["@dummy/chart.js", "chart.js", "array-flatten/dist/index"], function (___dummy_chartjs, __chartjs, __array_flatten_dist_indexjs) {
"use strict";
});"
`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
import "@dummy/chart.js";
import "chart.js";
import "array-flatten/dist/index.js";
4 changes: 2 additions & 2 deletions packages/plugin/src/modules/visitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ const hasGlobalExportFlag = (node) => hasJsdocGlobalExportFlag(node);
const addImport = (imports, imp, filename, first) => {
const existingImport = imports.find((i) => i.src === imp.src);
if (!existingImport) {
// if a module ends with the file extension ".js" and it can be resolved to
// if a module path ends with the file extension ".js" and it can be resolved to
// a local file having also the file extension ".js" and not ".js.js" then
// we need to slice the file extension to avoid redundant file extension
// (the require/define of UI5 always adds the file extension ".js" to the module name)
if (imp.src.indexOf(".js") != -1) {
if (/^(?:(@[^/]+)\/)?([^/]+)\/(.*)\.js$/.test(imp.src)) {
try {
const modulePath = require.resolve(imp.src);
if (modulePath.endsWith(imp.src.split("/").pop())) {
Expand Down