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
9 changes: 4 additions & 5 deletions packages/node-resolve/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
const builtins = new Set(builtinList);
const ES6_BROWSER_EMPTY = '\0node-resolve:empty.js';
const nullFn = () => null;
const deepFreeze = object => {
const deepFreeze = (object) => {
Object.freeze(object);

for (const value of Object.values(object)) {
Expand Down Expand Up @@ -100,10 +100,9 @@ export function nodeResolve(opts = {}) {
// ignore IDs with null character, these belong to other plugins
if (/\0/.test(importee)) return null;

// strip hash and query params from import
const [withoutHash, hash] = importee.split('#');
const [importPath, params] = withoutHash.split('?');
const importSuffix = `${params ? `?${params}` : ''}${hash ? `#${hash}` : ''}`;
// strip query params from import
const [importPath, params] = importee.split('?');
const importSuffix = `${params ? `?${params}` : ''}`;
importee = importPath;

const basedir = !importer || dedupe(importee) ? rootDir : dirname(importer);
Expand Down
3 changes: 3 additions & 0 deletions packages/node-resolve/test/fixtures/hash-in-path.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import test from 'test/#/foo';

export default test;
3 changes: 0 additions & 3 deletions packages/node-resolve/test/fixtures/hash.js

This file was deleted.

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

6 changes: 3 additions & 3 deletions packages/node-resolve/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,15 @@ test('handles package side-effects', async (t) => {
delete global.sideEffects;
});

test('can resolve imports with hashes', async (t) => {
test('can resolve imports with hash in path', async (t) => {
const bundle = await rollup({
input: 'hash.js',
input: 'hash-in-path.js',
onwarn: () => t.fail('No warnings were expected'),
plugins: [
nodeResolve(),
{
load(id) {
if (id === resolve(__dirname, 'fixtures', 'node_modules', 'test', 'index.js#foo')) {
if (id === resolve(__dirname, 'fixtures', 'node_modules', 'test', '#', 'foo.js')) {
return 'export default "resolved with hash"';
}
return null;
Expand Down