Skip to content

Commit

Permalink
issue #773 handle relative path exports from dependency entry points
Browse files Browse the repository at this point in the history
  • Loading branch information
thescientist13 committed Oct 17, 2021
1 parent e242b87 commit ff79b78
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
16 changes: 12 additions & 4 deletions packages/cli/src/plugins/resource/plugin-node-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,23 @@ const walkModule = (module, dependency) => {
ExportNamedDeclaration(node) {
const sourceValue = node && node.source ? node.source.value : '';

if (sourceValue !== '' && sourceValue.indexOf('.') !== 0 && sourceValue.indexOf('http') !== 0) {
updateImportMap(sourceValue, `/node_modules/${sourceValue}`);
if (sourceValue !== '' && sourceValue.indexOf('http') !== 0) {
if (sourceValue.indexOf('.') === 0) {
updateImportMap(`${dependency}/${sourceValue.replace('./', '')}`, `/node_modules/${dependency}/${sourceValue.replace('./', '')}`);
} else {
updateImportMap(sourceValue, `/node_modules/${sourceValue}`);
}
}
},
ExportAllDeclaration(node) {
const sourceValue = node && node.source ? node.source.value : '';

if (sourceValue !== '' && sourceValue.indexOf('.') !== 0 && sourceValue.indexOf('http') !== 0) {
updateImportMap(sourceValue, `/node_modules/${sourceValue}`);
if (sourceValue !== '' && sourceValue.indexOf('http') !== 0) {
if (sourceValue.indexOf('.') === 0) {
updateImportMap(`${dependency}/${sourceValue.replace('./', '')}`, `/node_modules/${dependency}/${sourceValue.replace('./', '')}`);
} else {
updateImportMap(sourceValue, `/node_modules/${sourceValue}`);
}
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,11 @@ describe('Develop Greenwood With: ', function() {
expect(importMap['@material/mwc-ripple/mwc-ripple']).to.equal('/node_modules/@material/mwc-ripple/mwc-ripple.js');
expect(importMap['@material/mwc-ripple/mwc-ripple/@material/mwc-ripple/mwc-ripple.js']).to.be.undefined;

// https://github.com/ProjectEvergreen/greenwood/issues/773
expect(importMap['@material/base/component']).to.equal('/node_modules/@material/base/component.js');
expect(importMap['@material/base/foundation']).to.equal('/node_modules/@material/base/foundation.js');
expect(importMap['@material/base/types']).to.equal('/node_modules/@material/base/types.js');

done();
});

Expand Down

0 comments on commit ff79b78

Please sign in to comment.