Skip to content

Commit 44a830b

Browse files
committed
fix: Disable buggy stray reference errors for now.
1 parent 3bddf41 commit 44a830b

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

packages/jsx-analyzer/src/transformer/babel.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323

2424
import isBlockFilename from '../utils/isBlockFilename';
2525
import { classnamesHelper as generateClassName, HELPER_FN_NAME } from './classNameGenerator';
26-
import { TemplateAnalysisError } from '../utils/Errors';
26+
// import { TemplateAnalysisError } from '../utils/Errors';
2727
let { parse } = require('path');
2828

2929
export interface CssBlocksVisitor {
@@ -151,7 +151,8 @@ function detectStrayReferenceToImport(
151151
if (binding) {
152152
for (let ref of binding.referencePaths) {
153153
if (!isRemoved(ref)) {
154-
throw new TemplateAnalysisError('Stray reference to block import. Imports are removed during rewrite.', {filename, ...ref.node.loc.start});
154+
console.warn(`WARNING: Stray reference to block import (${specifier.local.name}). Imports are removed during rewrite so this will probably be a runtime error. (${filename}:${ref.node.loc.start.line}:${ref.node.loc.start.column}`);
155+
// throw new TemplateAnalysisError(`Stray reference to block import (${specifier.local.name}). Imports are removed during rewrite.`, {filename, ...ref.node.loc.start});
155156
}
156157
}
157158
}

packages/jsx-analyzer/test/transformer/transformer-test.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { assert } from 'chai';
2-
import { suite, test } from 'mocha-typescript';
2+
import { suite, test, skip } from 'mocha-typescript';
33
import * as babel from 'babel-core';
44
import { StyleMapping, PluginOptionsReader, CssBlockOptions, BlockCompiler } from 'css-blocks';
55
import * as postcss from 'postcss';
@@ -411,6 +411,7 @@ export class Test {
411411
});
412412
}
413413

414+
@skip
414415
@test 'Left over references to the block are an error'(){
415416
mock({
416417
'bar.block.css': '.root { color: red; } .foo { color: blue; }',
@@ -436,7 +437,7 @@ export class Test {
436437
console.log(res.jsx.code);
437438
assert.ok(false, 'should not have succeeded.');
438439
}, e => {
439-
assert.equal(e.message, 'test.tsx: [css-blocks] AnalysisError: Stray reference to block import. Imports are removed during rewrite. (test.tsx:10:11)');
440+
assert.equal(e.message, 'test.tsx: [css-blocks] AnalysisError: Stray reference to block import (foo). Imports are removed during rewrite. (test.tsx:10:11)');
440441
});
441442
});
442443
}

0 commit comments

Comments
 (0)