Skip to content
Open
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
14 changes: 7 additions & 7 deletions browser_library_test/generate.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@ const generator = new Generator({
mapUrl: './lib/build/',
defaultProvider: 'nodemodules',
env: ['production', 'browser', 'module'],
// Work around jspm/generator#259
commonJS: true,
});

await generator.install('./cli-pkg-test');

const map = generator.getMap();

// Add ./packages/cli_pkg_test/build/ so that URLs can be resolved in the URL
// scheme generated by the test package.
const prefix = './packages/cli_pkg_test/build/';
// The @jspm/genearator resolves symlinks without a way to preserve them (unless
// file URLs are used). We have to manually restore the paths for the dart
// browser tests to work. This is a bit hacky, but it works for our use case.
const prefix = './packages/cli_pkg_test/build/cli-pkg-test/';
const concretePathPrefix = '../../build/npm/';
function addPrefixToValues(map) {
for (const [key, value] of Object.entries(map)) {
map[key] = prefix + value;
map[key] = value.replace(concretePathPrefix, prefix);
}
}

addPrefixToValues(map['imports']);

for (const [scope, imports] of Object.entries(map['scopes'])) {
delete map['scopes'][scope];
map['scopes'][prefix + scope] = imports;
map['scopes'][scope.replace(concretePathPrefix, prefix)] = imports;
addPrefixToValues(imports);
}

Expand Down
Loading
Loading