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

Fix RawAsset loading. #160

Merged
merged 5 commits into from
Dec 11, 2017
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 4 additions & 1 deletion src/assets/RawAsset.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ class RawAsset extends Asset {
load() {}

generate() {
const pathToAsset = JSON.stringify(
path.join(this.options.publicURL, this.generateBundleName())
Copy link
Member

Choose a reason for hiding this comment

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

will this cause a \ to be used on windows instead of /?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the heads up. On it.

Copy link
Contributor Author

@rakannimer rakannimer Dec 11, 2017

Choose a reason for hiding this comment

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

Done. I had misunderstood how modules are loaded. Thanks for the review !

);
return {
js: `module.exports=${JSON.stringify(this.generateBundleName())};`
js: `module.exports=${pathToAsset};`
};
}
}
Expand Down
14 changes: 8 additions & 6 deletions test/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ describe('javascript', function() {
assertBundleTree(b, {
name: 'index.js',
assets: ['index.js', 'bundle-loader.js', 'bundle-url.js'],
childBundles: [{
assets: ['local.js'],
childBundles: []
}]
childBundles: [
{
assets: ['local.js'],
childBundles: []
}
]
});

let output = run(b).default;
Expand Down Expand Up @@ -134,8 +136,8 @@ describe('javascript', function() {

let output = run(b);
assert.equal(typeof output, 'function');
assert(/^[0-9a-f]+\.txt$/.test(output()));
assert(fs.existsSync(__dirname + '/dist/' + output()));
assert(/^\/dist\/[0-9a-f]+\.txt$/.test(output()));
assert(fs.existsSync(__dirname + output()));
});

it('should minify JS in production mode', async function() {
Expand Down
4 changes: 2 additions & 2 deletions test/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ describe('typescript', function() {

let output = run(b);
assert.equal(typeof output.getRaw, 'function');
assert(/^[0-9a-f]+\.txt$/.test(output.getRaw()));
assert(fs.existsSync(__dirname + '/dist/' + output.getRaw()));
assert(/^\/dist\/[0-9a-f]+\.txt$/.test(output.getRaw()));
assert(fs.existsSync(__dirname + output.getRaw()));
});

it('should minify in production mode', async function() {
Expand Down