Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds baseUrl to web_modules imports #480

Merged
merged 1 commit into from
Jun 11, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,8 @@ export async function command(commandOptions: CommandOptions) {
return spec;
}
if (dependencyImportMap.imports[spec]) {
let resolvedImport = path.posix.resolve(
let resolvedImport = path.posix.join(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fine to me. Not sure why we were using resolve() before, since we seem to just be concatening, not resolving its on-disk location.

config.buildOptions.baseUrl,
`/web_modules`,
dependencyImportMap.imports[spec],
);
Expand All @@ -336,7 +337,7 @@ export async function command(commandOptions: CommandOptions) {
pkgName: missingPackageName,
},
});
return `/web_modules/${spec}.js`;
return path.posix.join(config.buildOptions.baseUrl, `/web_modules`, `${spec}.js`);
});
code = wrapImportMeta({code, env: true, hmr: false, config});
}
Expand Down
1 change: 0 additions & 1 deletion test/build/base-url/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
build
node_modules
5 changes: 5 additions & 0 deletions test/build/base-url/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ it('buildOptions.baseUrl', () => {
expect(iconMatch).toBe('/static/favicon.ico');
expect(cssMatch).toBe('/static/index.css');
expect(jsMatch).toBe('/static/_dist_/index.js');

// web_modules imports should be rewritten to add baseUrl
const outputJS = fs.readFileSync(path.resolve(__dirname, 'build', '_dist_', 'index.js'), 'utf8');

expect(outputJS).toContain('/static/web_modules/array-flatten.js');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

});
21 changes: 21 additions & 0 deletions test/build/base-url/node_modules/array-flatten/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions test/build/base-url/node_modules/array-flatten/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions test/build/base-url/node_modules/array-flatten/dist/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions test/build/base-url/node_modules/array-flatten/dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions test/build/base-url/node_modules/array-flatten/dist/index.spec.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.